【发布时间】:2014-08-04 09:26:19
【问题描述】:
我已经尝试了许多其他相关 StackOverflow 问题的解决方案,但我部署的应用程序仍然显示 白色矩形 框,而不是图标。在 localhost 上运行正常。
宝石文件
source 'https://rubygems.org'
gem 'rails', '4.0.2'
gem 'protected_attributes'
gem 'font-awesome-sass'
...
group :development, :test do
gem 'sqlite3' # Use sqlite3 as the database for Active Record
end
gem 'rails_12factor', group: :production
group :production do
gem 'pg'
gem 'rails_serve_static_assets'
end
application.css
*= require font-awesome
我已经预编译了资产,并修改了我的 application-xxx.css 文件(根据this answer)如下:
@font-face {
font-family: 'FontAwesome';
src: font-url('/assets/fontawesome-webfont.eot');
src: font-url('/assets/fontawesome-webfont.eot?#iefix') format('embedded-opentype'), font-url('/assets/fontawesome-webfont.woff') format('woff'), font-url('/assets/fontawesome- webfont.ttf') format('truetype'), font-url('/assets/fontawesome- webfont.svg#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
我的 production.rb 包含
config.serve_static_assets = true
当我加载应用程序时,控制台上没有错误但字体没有作为资源加载:
可能是什么问题?
编辑 问题解决了,恐怕我跑的时候没看控制台消息
rake assets:precompile RAILS_ENV=production
我有一些无效的 CSS,出于某种原因,在 localhost 中并不重要,但在生产中确实如此。顺便换了gem "font-awesome-rails"。
【问题讨论】:
标签: css ruby-on-rails heroku font-awesome