0

I am trying to use font-awesome, but upon running , I get the following error(s)

ActionController::RoutingError (No route matches [GET] "/assets/fonts/font-awesome/fontawesome-webfont.woff"):
....
ActionController::RoutingError (No route matches [GET] "/assets/fonts/font-awesome/fontawesome-webfont.ttf"):
....
ActionController::RoutingError (No route matches [GET] "/assets/fonts/font-awesome/fontawesome-webfont.svg"):

In my Gemfile I have:

 gem "font-awesome-rails"  # https://github.com/bokmann/font-awesome-rails

in my framework_and_overrides.css.scss I have:

// import the CSS framework
@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome";

In my application.css I have:

/*
...
*= require font-awesome
*= require dashboard/framework_and_overrides
....
*/

I added in my application.rb:

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

And I run rake assets:clobber , to start on a clean basis .. now way , same errors

Thanks for your enlightenments ...

Hristo Georgiev
  • 2,499
  • 1
  • 16
  • 23

1 Answers1

5

Remove from application.css:

*= require font-awesome

In your framework_and_overrides.css.scss add the following lines at the bottom:

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

UPDATE

It turns out you have an issue with the routing of the asset. Rails creates paths to assets depending if they are pre-compiled or not. The safest way to make things work in all cases (both production and development) is to put the routes in font_url ,like this:

@font-face {
  font-family: "FontAwesome";
  src: font_url('fontawesome-webfont.eot');
  src: font_url('fontawesome-webfont.eot?#iefix') format('eot'), font_url('fontawesome-webfont.woff') format('woff'), font_url('fontawesome-webfont.ttf') format('truetype'), font_url('fontawesome-webfont.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

Alternatively, you can link an external stylesheet (performance might get worse):

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
Hristo Georgiev
  • 2,499
  • 1
  • 16
  • 23
  • Thanks for your suggestion , I guess you are targeting the gem 'font-awesome-sass' ( sprockets does nt work w font-awesome-rails gem... ( I tried ) I removed the require, I added the 2 import lines and the asset.precompile... but , same errors , same message ... btw , in development mode , the pre-compile is not performed isn't it ?... –  Aug 21 '15 at 16:24
  • 1
    I guess I found the error : in my style.css , I have @font-face { font-family: 'FontAwesome'; src: url('../fonts/font-awesome/fonts/fontawesome-webfont.eot?v=4.1.0'); src: url('../fonts/font-awesome/fonts/fontawesome-webfont.eot?#iefix&v=4.1.0') format('embedded-opentype'), url('../fonts/font-awesome/fonts/fontawesome-webfont.woff?v=4.1.0') format('woff'), url('../fonts/font-awesome/fonts/fontawesome-webfont.ttf?v=4.1.0') format('truetype'), url('../fonts/font-awesome/fonts/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular') format('svg'); } ... the url is wrong !!!! –  Aug 21 '15 at 16:28
  • I just updated the solution. Let me know if this works – Hristo Georgiev Aug 21 '15 at 16:39
  • That's it ... thanks for your answer ... it's running fien , I got rid of this @font-face css entry .. ( I am reusing a template...) as everything is handled by the font-awesome-sass gem .... –  Aug 21 '15 at 16:45