The reason I always get initialized constant errors occurring in Ruby is accidentally naming models the plural form of the database table name and not letting Rails automatically create the pluralisations.
script/generate scaffold contact_skill contact_id:integer skill_id:integer description:string
not
script/generate scaffold contact_skills ...
(This reason is one I constantly forget, and Google never helps me. Now I will not forget)
—–
edit: I’ve had a LOAD of google hits from this search query in the last few days, if this helps you or doesn’t please leave a comment to make this article more complete.
Thanks for that David, saved me a few hours of heartache. Not suprised you have a lot of hits on this page, nether the books or site mention this rather important fact.
To help others that have this problem, I discovered the command to removing unwanted scaffolding …
“script/destroy scaffold contact_skills”
This cleans up the project nicely.
Best of luck with Ruby, am having long nights myself trying to get a decent site up and running with it, I think it’s worth it though having come from a .Net background and that really is painful.
A) Thanks for the reminder, this was a huge help. The comment about script/destroy is very helpful too.
B) If you want more comments, I would suggest changing your settings to make it easier for people to leave a post rather than creating an account. If you want to monitor that fine, that works, but WP has a pretty good system for getting rid of spam.
Thanks for the comments guys. Ryan, I’ve enabled FFA comments.. see how that goes!
I see I’m top of (my) google search for “Ruby Uninitialized Constant Error” … nice!
Hi David,
You just saved me a helluva long debugging time
I could not beleive I was getting an error this early after scaffolding
big up to rsmith for the command to rollback a scaffold
thx guys