Scaffolding generator issue in Rails 2.1+
I have a fresh installation of Rails 2.2, the thing is, everything works fine until I use the forest generator.
$ script/generate scaffold pages \
title:string description:string content:text
$ rake db:migrate
But when I start the server with this address: http: // localhost: 3000 / pages / I get this:
NoMethodError in PagesController#index
undefined method `find' for ActionController::Caching::Pages:Module
app/controllers/pages_controller.rb:5:in 'index'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in 'send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in 'perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in 'call_filters'
...
I can't get what I did wrong? Is this new Rails specific stuff?
+1
source to share
1 answer
The resource name must be singular. So try
script/generate scaffold page title:string description:string content:text
instead of pages .
Also, your call to the scaffold generator creates a Pages model that has the same name as the ActionController :: Caching :: Pages module available from your controller, and Rails gets confused (since the Pages module doesn't have a method like find).
+4
source to share