1

I'm using typicons and heroku in my rails app and its working locally but not in production, I'm not getting any routing error in heroku and I'm not sure what I'm missing. I have a fonts folder in the assets folder and I'm using

    config.assets.paths << Rails.root.join("app", "assets", "fonts")

inside my config.application.rb file under the application class.

Inside the typicons.css.scss (which is in the stylesheets folder) I have

@font-face {
  font-family: 'typicons';
  src: font-url('typicons.eot');
  src: font-url('typicons.eot?#iefix') format('embedded-opentype'),
       font-url('typicons.woff') format('woff'),
       font-url('typicons.ttf') format('truetype'),
       font-url('typicons.svg#typicons') format('svg');
  font-weight: normal;
  font-style: normal;
}
teddybear
  • 546
  • 2
  • 6
  • 14

1 Answers1

0

I spent a few hours on the same issue. The following is what worked for me:

Placed font files in assets/fonts

Inside the typicons.css.scss (which is in the stylesheets folder) I have:

/* @FONT-FACE loads font into browser */
@font-face {
  font-family: 'typicons';
  font-weight: normal;
  font-style: normal;
  src: font-url(asset-path('typicons.eot'));
  src: font-url(asset-path('typicons.eot?#iefix')) format('embedded-opentype'),
    font-url(asset-path('typicons.woff')) format('woff'),
    font-url(asset-path('typicons.ttf')) format('truetype'),
    font-url(asset-path('typicons.svg#typicons')) format('svg');
}

In application.rb, I added:

config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/

Finally, I ran the following before committing and pushing to Heroku:

RAILS_ENV=production bundle exec rake assets:precompile

I did not add the following line to application.rb:

config.assets.paths << Rails.root.join("app", "assets", "fonts")

If you run Rails.application.class.config.assets.paths in the Rails console, you should be able to see whether Rails is picking up the assets/fonts directory. In Rails 4.2.5, the fonts directory was added automatically to assets paths.

Hope this saves someone some time.

Cleverlemming
  • 1,310
  • 1
  • 8
  • 10