I am developing a Rails 4 app using the Active Admin gem for the administration back end. Active Admin in turn uses Devise for user authentication. Now, when I try to deploy
In config/initializers/devise.rb
I put:
config.secret_key = ENV["SECRET_KEY_BASE"] if Rails.env.production?
Because if you put:
$ heroku config
You'll see a secret_key_base
for the mode production
.
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.
I do not know right solution but it's working. You can try it. I was cloned my project from my GitLab account and when I run in my local server, I have an error Message:
rake aborted!
Devise.secret_key was not set. Please add the following to your Devise initializer:
config.secret_key = '-- secret key --'
Open config/initializers/devise.rb
and add this line
config.secret_key = '<%= ENV["SECRET_KEY_BASE"] %>'
This code line is solved my problem.
Could it be, that you did not run rails g devise:install
?
Running rails generate devise User
without the previous command does cause this problem.
Check if your config\initializers\secret_token.rb
has:
YourAppName::Application.config.secret_token
It should be:
YourAppName::Application.config.secret_key_base
This solved my problem:
Add the code below to your config/initializers/devise.rb file.
config.secret_key = '-- secret key --'
Replace '-- secret key--' with your own key. I recommend storing it in an ENV variable for security purpose.