Devise Secret Key was not set Devise Secret Key was not set ruby-on-rails ruby-on-rails

Devise Secret Key was not set


I ran bundle update this morning and started getting the same error.

I added it as a line in config/initializers/devise.rb and the error was fixed.

This seems to be the commit which introduced it.


What worked for me on Rails 4.1 and Devise 3.2.4 is in config/initializers/devise.rb:

config.secret_key = ENV['DEVISE_SECRET_KEY'] if Rails.env.production?


As of Devise 3.2.3 for Rails 4+ applications the key setting location defaults to YourAppName::Application.config.secret_key_base found in config/initializers/secret_token.rb