字体真棒没有加载图标 - Rails 4

时间:2014-01-31 19:00:53

标签: css ruby twitter-bootstrap ruby-on-rails-4 font-awesome

我在我的应用程序中使用twitter bootstrap,因为我正在使用ruby gem twitter-bootstrap-rails (2.2.8)。我已将rails版本升级为rails 4。

我正在使用以下宝石作为资产

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

现在问题是没有加载字体awesome的图标。它应该根据我的HTML <button type="submit" class="btn"><i class="icon-search"></i></button>

加载放大镜玻璃

enter image description here

这是我的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";

2 个答案:

答案 0 :(得分:9)

仍然不确定问题是什么,但我已将gem "font-awesome-rails"包含在Gemfile*= require font-awesome application.css中,之后一切正常。

答案 1 :(得分:0)

你也可以试试这个:

@font-face {
  font-family: "FontAwesome";
  src: url('<%= asset_path("fontawesome-webfont.eot") %>');
  src: url('<%= asset_path("fontawesome-webfont.eot") + "?#iefix" %>')   format('eot'), url('<%= asset_path("fontawesome-webfont.woff") %>') format('woff'), url('<%= asset_path("fontawesome-webfont.ttf") %>') format('truetype'), url('<%= asset_path("fontawesome-webfont.svg") + "#FontAwesome" %>') format('svg');
  font-weight: normal;
  font-style: normal;
  }