Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 864
Jay Godse Avatar asked Aug 01 '11 11:08

Jay Godse


1 Answers

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
like image 74
Preacher Avatar answered Oct 12 '22 05:10

Preacher