

書籍「現場Rails」のP292を参考に、gem「ransack」 を bundleコマンド
でインストールした後、Railsサーバ(puma)を再起動したら、このようなエラーがでました。  
自身が編集したファイルには'severity'も'saverity'も含まれていないため、NameErrorを出されてもチンプンカンプンです。

[code]

    Puma caught this error: undefined local variable or method `saverity' for #<Taskleaf::Application:0x0000557a7f925410>
    Did you mean?  severity (NameError)
    /root/taskleaf/config/environments/development.rb:18:in `block (2 levels) in <top (required)>'
    /root/.rbenv/versions/2.5.1/lib/ruby/2.5.0/logger.rb:584:in `format_message'
    /root/.rbenv/versions/2.5.1/lib/ruby/2.5.0/logger.rb:472:in `add'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.5/lib/active_support/logger.rb:89:in `add'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.5/lib/active_support/logger.rb:27:in `block (2 levels) in broadcast'
    /root/.rbenv/versions/2.5.1/lib/ruby/2.5.0/logger.rb:527:in `info'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.5/lib/rails/rack/logger.rb:37:in `call_app'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.5/lib/rails/rack/logger.rb:28:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionpack-5.2.5/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionpack-5.2.5/lib/action_dispatch/middleware/request_id.rb:27:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.5/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionpack-5.2.5/lib/action_dispatch/middleware/executor.rb:14:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionpack-5.2.5/lib/action_dispatch/middleware/static.rb:127:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.5/lib/rails/engine.rb:524:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/configuration.rb:227:in `call'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:706:in `handle_request'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:476:in `process_client'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:334:in `block in run'
    /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/thread_pool.rb:135:in `block in spawn_thread'
    
[/code]


CC BY-SA 4.0
2021-05-06T15:53:09.487
75704
2021-05-06T16:44:50.393
2021-05-06T16:44:50.393
3060
44901
question
ruby-on-rails
Rails エラー "Puma caught this error: undefined local variable or method"


自己解決しました。

[code]

    /root/taskleaf/config/environments/development.rb:18:in `block (2 levels) in <top (required)>' 
    
[/code]

タイプミスです。NameErrorを疑う前に、自分を疑うように気をつけます。  
また、思い込みから、直近に編集したファイル群を確認していました。  
エラーメッセージをしっかり読むように気をつけます。


CC BY-SA 4.0
2021-05-06T16:11:16.660
75705
2021-05-06T16:11:16.660
44901
75704
answer