本文介绍了Rails-image.png未预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Amazon EC2服务器上部署Web应用程序,并且代码已经存储在服务器上.一切看起来都正常,但是当我转到主页时,收到500错误消息,并且production.log文件给我以下错误:

I'm attempting to deploy a web application on Amazon's EC2 servers, and I have the code up on the server. Everything looks like it's working, but when I go to the home page, I get a 500 error message and the production.log file gives me the following error:

ActionView::Template::Error (image.png isn't precompiled)

  • 我已经尝试运行rake assets:precompile

    我已将config/environments/production.rb中的行更改为config.assets.compile = true

    但是我仍然遇到相同的错误.

    but I still get the same error.

    我正在运行Rails 3.2.6和Ruby 1.8.7.

    I'm running Rails 3.2.6 and Ruby 1.8.7.

    感谢您的帮助!

    推荐答案

    运行rake assets:precompile RAILS_ENV=production应该可以解决此问题.如果您不提供任何RAILS_ENV,Rails会认为它是development

    Running rake assets:precompile RAILS_ENV=production should fix it.If you don't provide any RAILS_ENV, Rails assumes it's development

    我认为这是因为资产管道中的每个环境都有不同的行为.因此,通常,在生产中,始终使用RAILS_ENV ='production'运行rake任务,您应该保持安全.

    I believe that's because each env in the asset pipeline behaves differently. Therefore, as a general rule, in production, always run rake tasks with RAILS_ENV='production' and you should stay safe.

    这篇关于Rails-image.png未预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 23:49