LoginSignup
3

More than 5 years have passed since last update.

Railsアプリをherokuにデプロイしたら、Devise.secret_key was not set.と出た時

Posted at

アプリをHerokuにデプロイ

% git push heroku master

で、エラーが出る場合

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        Devise.secret_key was not set. Please add the following to your Devise initializer:

.gitignore で secret.yml を無視していないか確認する

エラーメッセージに促されるまま config/initializer/devise.rb にsecret keyを追加してはならない・・

セキュリティを意識したつもりで、.gitignore に secret.yml を追加していると、このエラーがでる。

デフォルトの状態でproduction環境の分は環境変数から取ってくる状態になってるので、このままgitに入れてOK

secret.yml
production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

余計なことするんじゃなかった。。

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
3