我是个 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 的前端,它们也确实挂了
需要预编译
$ RAILS_ENV=production bundle exec rake assets:precompile
更重要的是,修改静态文件之后,必须再次预编译才行,我建议还是每次跑服务器时 precompile 一下吧。