LoginSignup
10
9

More than 5 years have passed since last update.

railsの実行でYou must set config.secret_key_base in your app's config.のエラーが出た時の対応

Last updated at Posted at 2014-12-18

問題

railsのサーバを立ち上げ、そのサーバのアドレス(http://localhost:3000)にアクセスするとブラウザ上にエラーが表示。

kobito.1418908943.958830.png

コマンドライン上には以下のエラーが表示されました。

DEPRECATION WARNING: You didn't set config.secret_key_base. Read the upgrade documentation to learn more about this new config option. (called from service at /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138)
[2014-12-18 13:15:07] ERROR RuntimeError: You must set config.secret_key_base in your app's config.
    /var/lib/gems/1.9.1/gems/railties-4.0.5/lib/rails/application.rb:145:in `env_config'
    /var/lib/gems/1.9.1/gems/railties-4.0.5/lib/rails/engine.rb:507:in `call'
    /var/lib/gems/1.9.1/gems/railties-4.0.5/lib/rails/application.rb:97:in `call'
    /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
    /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
    /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
    /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    /usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
DEPRECATION WARNING: You didn't set config.secret_key_base. Read the upgrade documentation to learn more about this new config option. (called from service at /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138)
[2014-12-18 13:15:07] ERROR RuntimeError: You must set config.secret_key_base in your app's config.
    /var/lib/gems/1.9.1/gems/railties-4.0.5/lib/rails/application.rb:145:in `env_config'
    /var/lib/gems/1.9.1/gems/railties-4.0.5/lib/rails/engine.rb:507:in `call'
    /var/lib/gems/1.9.1/gems/railties-4.0.5/lib/rails/application.rb:97:in `call'
    /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
    /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
    /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
    /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    /usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

対応

railsのバージョンが問題のようです。gemfileを開いてrailsのバージョンを4.0.5から4.1.0にしました。

gem 'rails', '4.0.5'

上記を次のように変更した。

gem 'rails', '4.1.0'

その後にbundleのupdateをした。

bundle update

サーバを起動させてた後、無事アクセスに成功。

rails server
10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9