CAVaLRy – Or, how to easily remember how to set up new MVC pages
Monroe Mann
Published On: Oct 23, 2024
Editor’s Note: On all blog posts, we try to edit the writing as little as possible to preserve authenticity, personality, and writing style. We typically fix spelling errors, but minimally modify grammar and sentence structure (just enough to ensure readability).
Name: Monroe Mann Break Diving Level: Level 1 Number of Certified Dives: 14 From: United States In: United States
So, as I was making new pages (coding in Ruby on Rails), I inevitably would forget something. I would forget to set up the routes. Or I’d forget to create a link to the new page. Or I’d forget to create the controller.
It started to become really frustrating, so I created this simple acronym to help me remember all the steps. Whenever I create a new page, it’s time to call in the cavalry!
Or… “CAVaLRy”.
The C = Controller, i.e. be sure to set up the controller
The A = Action (or Method), i.e. be sure to set up the actual page within the controller
The V = View, i.e. be sure to create an actual html page for what you’re trying to do
The L = Link, i.e. be sure there is a link from another page on the site to the new page
The R = Routes, i.e. be sure to set up the routes for the link that you just created
The ‘a’ and the ‘y’ are not used.
You don’t necessarily have to follow the steps in order. The point is to use this acronym as a checklist, i.e. “Did I do everything I need for the new page to work?”
Sometimes, you don’t need to do all the steps, e.g. the controller is already created, or you already have a view that you are going to use. But it’s a handy tool to make sure you don’t forget anything.
Whenever I create a new page, I will call in the CAVaLRy and verify that I haven’t forgotten anything. More often than not, when I use this method, it ensures that the page loads correctly the first time.
And if it doesn’t, no problem: call in the CAVaLRy again as a troubleshooting tool: is is the C? The A? The V? The L? or the R? The problem generally HAS to be in one of those five areas: the controller, the action, the view, the link, or the routes.
I hope you find this helpful!
Break Diving, Inc. is a tax-exempt 501(c)(3) charitable organization.
Read all about our amazing mission at www.BreakDiving.org
Join our free community at www.breakdiving.io
Like what we do? Please make a feel-good donation!
Remember to tell your friends about this www.BreakDiving.blog