2

This seems to be a popular issue, since I found many similar questions on Stack Overflow:

However, none of the above seems to help fix my problem.

Here is my situation:

  1. 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.
  2. 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.
  3. 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?

Community
  • 1
  • 1
Thibaud Clement
  • 6,607
  • 10
  • 50
  • 103
  • You can do a `heroku config -a app_name` to see what environment variables you have set. Devise should use your app's secret_key_base by default in Rails 4 applications. – dinjas Oct 13 '15 at 01:30
  • Thanks for your answer. I have `SECRET_KEY_BASE` already set when I run the command you recommend. From there, what should I do next to try and fix my problem? – Thibaud Clement Oct 13 '15 at 01:49
  • Did you try restarting your application? `heroku restart -a app_name` – dinjas Oct 13 '15 at 01:52
  • Just tried it. Still get the same error message. I just noticed something: each time I get the error, the secret key suggested in the Terminal changes. – Thibaud Clement Oct 13 '15 at 02:15

1 Answers1

0

I found a solution to this problem.

Instead of keeping on struggling with the font-awesome-rails gem, I uninstalled it and replaced it with font-awesome-sass, which is the official Font Awesome gem for rails.

Following the guidelines offered here (section: EASY: SASS Ruby Gem), I then ran bundle and added:

@import "font-awesome-sprockets";
@import "font-awesome";

to my application.scss file.

I also removed the old @import "font-awesome.css"; line from the very same file.

Now, Font Awesome works both locally and on Heroku.

Thibaud Clement
  • 6,607
  • 10
  • 50
  • 103