RoR 应用程序:“资产‘application.css’不存在于资产管道中";转移到生产服务器后 [英] RoR App: "The asset 'application.css' is not present in the asset pipeline" after moving to production server

查看:91
本文介绍了RoR 应用程序:“资产‘application.css’不存在于资产管道中";转移到生产服务器后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的 Ruby on Rails 应用程序移动到生产服务器 (AWS EC2 Amazon Linux 2018.03) 后,页面不呈现,因为错误资产管道中不存在资产‘application.css’"(存在预编译文件在公共/资产中):production.log

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.

我遵循了帖子中的提示:application.css 不在资产管道中,但没有帮助.

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

我的堆栈:

  • 红宝石 2.6.3
  • 导轨 5.2.3
  • 独角兽 5.5.1
  • nginx 1.14.1

如果有任何提示,我将不胜感激.

I will be really grateful for any hints.

推荐答案

您可以确认您的 app/assets/stylesheets 文件夹中应该有 application.css 文件,并且您必须在 go/start server 之前在生产环境中预编译资产生产环境.您可以使用

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

如果它仍然不起作用,那么您可以尝试在 production.rb 中将 config.assets.compile 选项设置为 true,以便它进行实时编译.虽然在生产环境中应该是false,因为它会影响性能.

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

这篇关于RoR 应用程序:“资产‘application.css’不存在于资产管道中";转移到生产服务器后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆