Rails4:heroku pushでエラーNoMethodError: undefined method `web_console’

Published on:
Last updated:

This post is also available in: 日本語 (Japanese)

Rails4で開発をしていて、ローカル開発環境から heroku push すると以下のエラーが出る場合のメモです。

NoMethodError: undefined method `web_console' for #<Rails::Application
/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/railtie/configuration.rb:95:in `method_missing'

上記のエラーはconfig/application.rb の以下の内容を、config/environments/development.rb に移動することで解決します。

config.web_console.whitelisted_ips = %w( 127.0.0.1 192.168.0.100 10.0.2.2 )

herokuはデフォルトでRailsはproduction環境での実行になっています。
なので、webconsoleはローカルのdevelopment環境でのみ使うという設定になります。
herokuで本番環境と同じ条件で試したい場合には、staging環境にするという方法もあります。

参考:
https://github.com/rails/web-console/issues/133

About
Kuniyoshi Takemoto is the founder of Amelt.net LLC, and editor of this blog(www.amelt.net).Learn more and follow me on LinkedIn.