undefined method `underscore' for nil
Closed this issue · 0 comments
jagthedrummer commented
I first did this, which worked as expected:
rails g super_scaffold Event Team name:text_field starts_at:date_and_time_field
Then ran rails db:migrate
and was able to create an Event.
Then I did this, which threw an error:
rails g super_scaffold Task Team event_id:super_select
which produced this output and threw this error:
Generating Task model with 'bin/rails generate model Task team:references event:references'
Writing './app/controllers/account/tasks_controller.rb'.
Fixing Standard Ruby on './app/controllers/account/tasks_controller.rb'.
Writing './app/views/account/tasks/index.html.erb'.
Writing './app/views/account/tasks/_menu_item.html.erb'.
Writing './app/views/account/tasks/_index.html.erb'.
Writing './app/views/account/tasks/_task.html.erb'.
Writing './app/views/account/tasks/edit.html.erb'.
Writing './app/views/account/tasks/show.html.erb'.
Writing './app/views/account/tasks/_form.html.erb'.
Writing './app/views/account/tasks/new.html.erb'.
Writing './app/views/account/tasks/_breadcrumbs.html.erb'.
Writing './app/views/api/v1/tasks/_task.json.jbuilder'.
Writing './app/views/api/v1/tasks/index.json.jbuilder'.
Writing './app/views/api/v1/tasks/show.json.jbuilder'.
Writing './config/locales/en/tasks.en.yml'.
Writing './app/controllers/api/v1/tasks_controller.rb'.
Fixing Standard Ruby on './app/controllers/api/v1/tasks_controller.rb'.
Writing './test/controllers/api/v1/tasks_controller_test.rb'.
Fixing Standard Ruby on './test/controllers/api/v1/tasks_controller_test.rb'.
Updating './test/factories/tasks.rb'.
Updating './app/models/team.rb'.
Updating './test/controllers/api/v1/tasks_controller_test.rb'.
Updating './test/controllers/api/v1/tasks_controller_test.rb'.
Updating './app/views/account/teams/show.html.erb'.
Updating './app/views/api/v1/open_api/index.yaml.erb'.
Updating './app/views/api/v1/open_api/index.yaml.erb'.
Updating './app/models/task.rb'.
Updating './app/models/task.rb'.
Updating './app/models/task.rb'.
Updating './app/models/task.rb'.
/Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/scaffolding/transformer.rb:761:in `block in add_attributes_to_various_views': undefined method `underscore' for nil (NoMethodError)
short = attribute.options[:class_name].underscore.split("/").last
^^^^^^^^^^^
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/scaffolding/transformer.rb:632:in `each'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/scaffolding/transformer.rb:632:in `each_with_index'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/scaffolding/transformer.rb:632:in `add_attributes_to_various_views'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/scaffolding/transformer.rb:1445:in `scaffold_crud'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/bullet_train/super_scaffolding/scaffolders/crud_scaffolder.rb:95:in `run'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/scaffolding/script.rb:235:in `<main>'
from <internal:/Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from <internal:/Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/zeitwerk-2.6.15/lib/zeitwerk/kernel.rb:34:in `require'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/bullet_train/super_scaffolding.rb:29:in `run'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bullet_train-super_scaffolding-1.7.10/lib/generators/super_scaffold/super_scaffold_generator.rb:32:in `generate'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `block in invoke_all'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `each'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `map'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `invoke_all'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/group.rb:232:in `dispatch'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/railties-7.1.3.3/lib/rails/generators.rb:261:in `invoke'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/railties-7.1.3.3/lib/rails/commands/generate/generate_command.rb:26:in `perform'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/railties-7.1.3.3/lib/rails/command/base.rb:178:in `invoke_command'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/railties-7.1.3.3/lib/rails/command/base.rb:73:in `perform'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/railties-7.1.3.3/lib/rails/command.rb:71:in `block in invoke'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/railties-7.1.3.3/lib/rails/command.rb:149:in `with_argv'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/railties-7.1.3.3/lib/rails/command.rb:69:in `invoke'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/railties-7.1.3.3/lib/rails/commands.rb:18:in `<main>'
from <internal:/Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from <internal:/Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /Users/jgreen/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from bin/rails:4:in `<main>'
If I manually include the class_name
like this, then it works:
rails g super_scaffold Task Team event_id:super_select{class_name=Event}