RoR App: “The asset 'application.css' is not present in the asset pipeline” after moving to production server

荒凉一梦 提交于 2019-12-24 06:34:12

问题


after moving my Ruby on Rails app to production server (AWS EC2 Amazon Linux 2018.03) pages don't render, because of error "The asset 'application.css' is not present in the asset pipeline" (precompiled files are presents in public/assets): production.log

However, when I refresh my application (sometimes more then once), this file is found in cache and page is rendering correctly. It seems like server doesn't wait for file precompilation or something like that. It happens not only on first page entry, but every change of view.

I followed tips from post: application.css not in asset pipeline, but it didn't help.

My stack:

  • ruby 2.6.3
  • rails 5.2.3
  • Unicorn 5.5.1
  • nginx 1.14.1

I will be really grateful for any hints.


回答1:


You can confirm your app/assets/stylesheets folder it should have application.css file and you will have to precompile assets in production environment before go/start server in production environment. You can precompile assets using

RAILS_ENV=production rails assets:precompile

If it still does not work then you can try the config.assets.compile option to true in production.rb so it will do live compilation. Although it should be false in production environment as it impact on performance.

config.assets.compile = true


来源:https://stackoverflow.com/questions/56753564/ror-app-the-asset-application-css-is-not-present-in-the-asset-pipeline-afte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!