This seems to be a popular issue, since I found many similar questions on Stack Overflow:
- Devise Token Auth error: Devise.secret_key was not set
- Devise Secret Key was not set
- Mina and Devise.secret_key was not set
However, none of the above seems to help fix my problem.
Here is my situation:
- I installed Font Awesome with the
font-awesome-rails
gem, and it was working locally, but whenever I deployed to Heroku, Font Awesome icons were no longer appearing. - So, I looked for answers to fix this problem, and found out that I needed to run
RAILS_ENV=production bundle exec rake assets:precompile
to make things work. - However, when I run this command, I get the following error in Terminal:
rake aborted!
Devise.secret_key was not set. Please add the following to your Devise initializer:
config.secret_key = '—— MY_SECRET_KEY_HERE ———'
Please ensure you restarted your application after installing Devise or setting the key.
As per the solutions offered in the questions mentioned at the beginning of my question, I do haveconfig.secret_key = ENV['DEVISE_SECRET_KEY'] if Rails.env.production?
in devise.rb
Also, as recommended here, I did run heroku config:set DEVISE_SECRET_KEY='—— MY_SECRET_KEY_HERE ———' -- app name_of_my_app_here
.
Because I was not sure, I also ran heroku config:set DEVISE_SECRET_KEY=—— MY_SECRET_KEY_HERE ——— -- app name_of_my_app_here
(without single quotes around my secret key).
But none of these things worked.
I keep getting the same error.
What am I doing wrong?