Fernando Brito wrote:
> Why does:
>
> *$ rails g controller project*
> Generates *app/controllers/project_controller.rb*
>
> and
>
> *$ rails g scaffold_controller project*
> Generates *app/controllers/projects_controller.rb* and
> *app/views/projects/*
This is by design. Consider:
$ rails g scaffold project name:string
You will notice an output containing something like:
invoke active_record
create db/migrate/20100602201538_create_projects.rb
create app/models/project.rb
invoke test_unit
create test/unit/project_test.rb
create test/fixtures/projects.yml
route resources :projects
invoke scaffold_controller
create app/controllers/projects_controller.rb
Notice also the following line in the output:
invoke scaffold_controller
So, the scaffold_controller generator assumes the full MVC stack from
model, through controller, to the views. In other words, running
scaffold_controller assumes you already have a Project model and assumes
the plural form that is the convention for controllers representing
model objects.
$ rails g controller project
This makes no assumptions about anything and simply creates a controller
file by appending _controller.rb to the name you supply to the
generator.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.