Chronicling my experiences with ruby on rails, web application development/management.

Thursday, March 12, 2009

Weird script/generate scaffold behaviour

As always feel free to correct me if i'm wrong, but here is some wacky behaviour i got when i used the following code to generate scaffolding from rails 2.2.2 core (i.e., no plugins or scaffolding generator plugins at all)


script/generate scaffold affiliate name:string user_id:integer


What was happening to my code was views not being found. restful paths not being found, even when i triple checked my routes file. To solve this i simply reran the code with a capital letter for the model name, as shown below.


What should the code be??


script/generate scaffold Affiliate name:string user_id:integer


Treat scaffold like every model is always CamelCase


By that i mean no matter what the name of your model is going to be always Capitalize the main words for that model. So single word models like Ass, Border, User are good. Never start with a lowercase ass, border or user.


This is just a rule i follow, as i've yet to see it let me down. It might just have been a momentary blip we all experience in our coding life, however capitalized models have never shown me that blip to date, so i'll run with it!

No comments:

Post a Comment