Versions:
- ruby:
3.3.5
- rails:
7.2.1
I’m receiving the following error when trying to run rails g scaffold Photo
gems/jbuilder-2.13.0/lib/generators/rails/templates/controller.rb:11:in block in template': undefined method all' for module ActiveModel (NoMethodError)
Full Stack Trace
invoke active_record
create db/migrate/20240927035144_create_photos.rb
create app/models/photo.rb
invoke test_unit
create test/models/photo_test.rb
create test/fixtures/photos.yml
invoke resource_route
route resources :photos
invoke scaffold_controller
Users/prometheus/.gem/ruby/3.3.5/gems/jbuilder-2.13.0/lib/generators/rails/templates/controller.rb:11:in `block in template': undefined method `all' for module ActiveModel (NoMethodError)
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/file_manipulation.rb:347:in `block in capture'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/file_manipulation.rb:354:in `with_output_buffer'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/file_manipulation.rb:347:in `capture'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/generators/base.rb:297:in `module_namespacing'
from /Users/prometheus/.gem/ruby/3.3.5/gems/jbuilder-2.13.0/lib/generators/rails/templates/controller.rb:5:in `template'
from /Users/prometheus/.rubies/ruby-3.3.5/lib/ruby/3.3.0/erb.rb:429:in `eval'
from /Users/prometheus/.rubies/ruby-3.3.5/lib/ruby/3.3.0/erb.rb:429:in `result'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/file_manipulation.rb:128:in `block in template'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/create_file.rb:54:in `render'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/create_file.rb:47:in `identical?'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/create_file.rb:74:in `on_conflict_behavior'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/empty_directory.rb:115:in `invoke_with_conflict_check'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/create_file.rb:61:in `invoke!'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions.rb:93:in `action'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/create_file.rb:25:in `create_file'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/actions/file_manipulation.rb:124:in `template'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/generators/named_base.rb:25:in `block in template'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/generators/named_base.rb:45:in `inside_template'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/generators/named_base.rb:24:in `template'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb:24:in `create_controller_files'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:134:in `block in invoke_all'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:134:in `each'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:134:in `map'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:134:in `invoke_all'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/group.rb:243:in `dispatch'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:116:in `invoke'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/group.rb:288:in `block in _invoke_for_class_method'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/shell.rb:68:in `with_padding'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/group.rb:277:in `_invoke_for_class_method'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/group.rb:134:in `_invoke_from_option_scaffold_controller'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:134:in `block in invoke_all'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:134:in `each'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:134:in `map'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:134:in `invoke_all'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/group.rb:243:in `dispatch'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/generators.rb:261:in `invoke'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/commands/generate/generate_command.rb:26:in `perform'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/command/base.rb:178:in `invoke_command'
from /Users/prometheus/.gem/ruby/3.3.5/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/command/base.rb:73:in `perform'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/command.rb:71:in `block in invoke'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/command.rb:149:in `with_argv'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/command.rb:69:in `invoke'
from /Users/prometheus/.gem/ruby/3.3.5/gems/railties-7.2.1/lib/rails/commands.rb:18:in `<main>'
from /Users/prometheus/.rubies/ruby-3.3.5/lib/ruby/3.3.0/bundled_gems.rb:75:in `require'
from /Users/prometheus/.rubies/ruby-3.3.5/lib/ruby/3.3.0/bundled_gems.rb:75:in `block (2 levels) in replace_require'
from /Users/prometheus/.gem/ruby/3.3.5/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from bin/rails:4:in `<main>'
It appears to happen when the generator gets to the scaffold_controller
command.
What’s also strange is that running bin/rails g scaffold_controller Photo
by itself works fine.
I’m a realtively new to rails (but have 10 years experience in other stacks) so I’m confused what’s going on. The most elaborate thing I’ve done is use the brick
gem to scaffold some controllers and models from an existing db. Other than that it’s a pretty fresh rails app.
This does not happen on a totally new rails app, so there is something funky with my setup.
Let me know if there is any other details to providde, thanks!!