【发布时间】:2012-03-27 15:11:29
【问题描述】:
我刚刚升级到 Rails 3.1 和 Asset Pipeline,但我无法弄清楚为什么我的字体不再被读取。我已经尝试了这篇文章中的答案(没有运气): Using @font-face with Rails 3.1 app?
目前,我正在尝试选择的解决方案。我在 app/assets 下有一个字体文件夹。文件名正确且存在于字体目录中。
在我的 Application.rb 中
config.assets.paths << "#{Rails.root}/app/assets/fonts"
我也尝试过,来自 Rails 指南 (http://guides.rubyonrails.org/asset_pipeline.html):
config.assets.paths << Rails.root.join("app", "assets", "fonts")
使用此代码,运行代码时路径映射到此
src: url('/assets/League_Gothic-webfont.eot
在我的 CSS 中:
@font-face {
font-family: "League_Gothic";
src: url('<%= asset_path('League_Gothic-webfont.eot') %>');
font-weight: normal;
font-style: normal;
}
当我尝试其他解决方案时,基本上是对路径进行硬编码:
src: url(/assets/fonts/League_Gothic-webfont.eot);
单击页面源代码中的链接时出现此错误:
No route matches [GET] "/assets/fonts/League_Gothic-webfont.eot"
【问题讨论】: