Ruby/Rails: where is the code to generate scaffolds
I was browsing the code at github.com/rails/rails, and I couldn't figure out where the开发者_开发技巧 code was to generate Rails scaffolds. Can anybody shed some light on this?
https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
Did you find that? If you track down it's require, resource_generator, you'll find the code that creates the route. If you track down the resource_generator's requires, you'll find the model generator, helper generator, etc.
You won't find any single file that generates everything.
If I totally misunderstood your question and you just want to know what the command is, it's:
cd your/application/directory
Rails version < 3.0.0
script/generate scaffold model_name column_name:column_type
Rails version > 3.0.0
rails g scaffold model_name column_name:column_type
精彩评论