I’m getting a nasty NoMethodError when running the scaffold generator on
a
Rails 3.0.3 project that was upgraded from a Rails 2 project. The
following
command works fine on a new Ralis 3.0.3 project:
rails g scaffold variant_location name:string description:string
code:string
…but fails for an existing project with the error:
invoke active_record
create db/migrate/20101220190429_create_variant_locations.rb
identical app/models/variant_location.rb
invoke test_unit
identical test/unit/variant_location_test.rb
identical test/fixtures/variant_locations.yml
route resources :variant_locations
invoke scaffold_controller
(erb):5:in template': undefined method
all’ for ActiveModel:Module
(NoMethodError)
from
/Users/preston/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/erb.rb:753:in
`eval’
from
/Users/preston/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/erb.rb:753:in
`result’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:111:in
`block in template’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in
`call’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in
`render’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:47:in
`identical?’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:73:in
`on_conflict_behavior’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:111:in
`invoke_with_conflict_check’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:61:in
`invoke!’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions.rb:95:in
`action’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:26:in
`create_file’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:110:in
`template’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb:14:in
`create_controller_files’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/task.rb:22:in
`run’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:118:in
`invoke_task’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
`block in invoke_all’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
`each’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
`map’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
`invoke_all’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/group.rb:226:in
`dispatch’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:109:in
`invoke’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/group.rb:269:in
`block in _invoke_for_class_method’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/shell.rb:74:in
`with_padding’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/group.rb:258:in
`_invoke_for_class_method’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/group.rb:150:in
`_invoke_from_option_scaffold_controller’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/task.rb:22:in
`run’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:118:in
`invoke_task’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
`block in invoke_all’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
`each’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
`map’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
`invoke_all’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/group.rb:226:in
`dispatch’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.6/lib/thor/base.rb:389:in
`start’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/generators.rb:163:in
`invoke’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/generate.rb:10:in
`<top (required)>’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in
`require’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in
`block in require’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in
`block in load_dependency’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in
`new_constants_in’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in
`load_dependency’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in
`require’
from
/Users/preston/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:17:in
`<top (required)>’
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Actually, every “generate scaffold” command fails in this app, leading
me
to believe that something in my custom code (or one of the libraries) is
causing it to explode. Unfortunately I have no idea what the issue is.
Ideas?
Preston