Ishank Gupta Ishank Gupta - 1 year ago 88
Ruby Question

Font awesome not loading icons - Rails 4

I am using twitter bootstrap in my app and for that I am using ruby gem

twitter-bootstrap-rails (2.2.8)
. I have upgraded the rails version to rails 4.

I am using following gems for assets

gem 'less-rails'
gem 'coffee-rails'
gem 'twitter-bootstrap-rails'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby

Now the problem is that icon of font awesome is not loading. It should load the magnifier glass as per my HTML
<button type="submit" class="btn"><i class="icon-search"></i></button>

enter image description here

Here is my bootstrap_and_overrides.css.less

@import "twitter/bootstrap/bootstrap";
@import "twitter/bootstrap/responsive";

// Set the correct sprite paths
@iconSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings");
@iconWhiteSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings-white");

// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
// Note: If you use asset_path() here, your compiled bootstrap_and_overrides.css will not
// have the proper paths. So for now we use the absolute path.
@fontAwesomeEotPath: asset-path("fontawesome-webfont.eot");
@fontAwesomeEotPath_iefix: asset-path("fontawesome-webfont.eot#iefix");
@fontAwesomeWoffPath: asset-path("fontawesome-webfont.woff");
@fontAwesomeTtfPath: asset-path("fontawesome-webfont.ttf");
@fontAwesomeSvgPath: asset-path("fontawesome-webfont.svg");

// Font Awesome
@import "fontawesome/font-awesome";

// Glyphicons
//@import "twitter/bootstrap/sprites.less";

Answer Source

Still not sure what the problem was, but I have included gem "font-awesome-rails" in my Gemfile and *= require font-awesome in my application.css, after that everything worked fine.