新手问题 [已解决] Rails 生产模式下 CSS 编译错误问题

somejump · 2015年06月09日 · 最后由 rei 回复于 2015年06月09日 · 2039 次阅读

我是个 rails 新手,对于 Rails 服务器 CSS 的预编译不是很熟悉 首先在 application 里面写下 CSS

*= require_self
*= require home
*= require font-awesome
*= require simditor
*= require semantic-new

之后访问服务器打开浏览器 console 就有这些错误信息:

Failed to load resource: the server responded with a status of 404 (Not Found)  http://XXXXX.com/assets/simditor-34400bcae1af61814cc649711017c00f.css?body=1
Failed to load resource: the server responded with a status of 404 (Not Found) http://XXXXX.com/assets/font-awesome-5f75b3a88debb91572b2a6fc0436be29.css?body=1  

等等,这些加入的 CSS 全挂了,我实际看了看那些用到 CSS 的前端,它们也确实挂了

所以这是怎么一回事呢?为什么 development 下什么事都没有呢?

需要预编译

$ RAILS_ENV=production bundle exec rake assets:precompile

更重要的是,修改静态文件之后,必须再次预编译才行,我建议还是每次跑服务器时 precompile 一下吧。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号