If that title threw you off, don’t worry it will make sense in a moment.
The other day, the mentors threw my class a bit of curveball. They asked us to take a program we built to output payroll data for a hypothetical company and display the same information (and more) to the browser through a Rails application.
Naturally we were all stoked at the learning opportunity. /sarcasm
rails new annoying_ass_payroll_challenge
I began to load the classes from the program into my models folder and when I’d run the program on localhost I would receive (beautiful, thanks to the better_errors gem) errors that declared my Constants to be “uninitialized”.
I struggled with this for a long time, several hours at least over the course of two days. Finally I called over a mentor when I thought that I was falling too far behind.
On that day, I learned a valuable lesson about Rails:
THE NAME OF YOUR FILES MUST BE UNDERSCORED TO CORRESPOND EXACTLY WITH YOUR CAMELCASED MODEL. For example:
So the name of this^ file MUST BE commissioned_sales_person.rb.
If you’re new to Rails like me: you’re welcome. This moment of enlightenment will probably save you hours of fruitless troubleshooting. But I am going to do more for you, since learning this little tidbit has done so much for me in terms of propelling my investigation into the Rails documentation.