Heroku / Ruby-on-Rails错误:图像不能预编译 [英] Heroku / Ruby-on-Rails error: image not precompiling

查看:153
本文介绍了Heroku / Ruby-on-Rails错误:图像不能预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ----->我知道Heroku正在运行rake资产:预编译任务:编写config / database.yml以从DATABASE_URL读取
----->为Rails资产管道准备应用程序
运行:rake资产:预编译
-----> Rails插件注入
注入rails_log_stdout
注入rails3_serve_static_assets
----->发现过程类型
Procfile声明类型 - > (无)
Ruby / Rails的默认类型 - >控制台,耙子,网络,工人
----->编译的段塞大小为17.7MB
----->启动...完成

我告诉它在production.rb中预编译图像

 #来自:http://stackoverflow.com/questions/8052865/rails-3-1-asset-pipeline-why-my-images-不要预编译生产
config.assets.precompile + =%w [*。png * .jpg * .jpeg * .gif]

那么为什么我仍然会得到这个500错误?

  2012 -05-29T02:57:15 + 00:00 app [web.1]:在2012-05-29 02:57:15 +0000 
开始GET/ signin为46.114.68.16 2012-05- 29T02:57:15 + 00:00 app [web.1]:通过SessionsController处理#new as HTML
2012-05-29T02:57:15 + 00:00 app [web.1]:渲染会话/在布局/应用程序中的new.html.erb(25.4ms)
2012-05-29T02:57:15 + 00:00应用程序[web.1]:在27ms内完成500次内部服务器错误
2012- 05-29T02:57:15 + 00:00 app [web.1]:
2012-05-29T02:57:15 + 00:00 app [web.1]:ActionView :: Template :: Error twitter_64.png未预编译):
2012-05-29T02:57:15 + 00:00 app [web .1]:25:< div id =auths>
2012-05-29T02:57:15 + 00:00 app [web.1]:27:< a href =/ auth / twitterclass =provider>
2012-05-29T02:57:15 + 00:00 app [web.1]:26:< h2>或通过以下其中一种登录:< / h2>
2012-05-29T02:57:15 + 00:00 app [web.1]:28:<%= image_tagtwitter_64.png,:size => 64x64,:alt => Twitter%> Twitter< / a>

有趣的是,我在其他页面上显示的图像显示得很好。不知道为什么一些图像不起作用,但有些会... ...

解决方案

首先,确保你有这个设置为:

  config.assets.initialize_on_precompile = false 

如果这不起作用,那么在构建slug之前尝试手动运行预编译任务是值得的;我认为这样做会有细微的差别:

  RAILS_ENV =生产包exec rake资产:预编译
code>

最后,这不是一个解决方案,但如果所有其他方法都失败了,临时解决方法是设置

  config.assets.compile = true 


I know that Heroku is running the rake assets:precompile task:

-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
-----> Rails plugin injection
       Injecting rails_log_stdout
       Injecting rails3_serve_static_assets
-----> Discovering process types
       Procfile declares types      -> (none)
       Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size is 17.7MB
-----> Launching... done

And I told it to precompile images in production.rb

# from: http://stackoverflow.com/questions/8052865/rails-3-1-asset-pipeline-why-my-images-do-not-precompile-for-production
config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif] 

So why do I still get this 500 error?

2012-05-29T02:57:15+00:00 app[web.1]: Started GET "/signin" for 46.114.68.16 at 2012-05-29 02:57:15 +0000
2012-05-29T02:57:15+00:00 app[web.1]: Processing by SessionsController#new as HTML
2012-05-29T02:57:15+00:00 app[web.1]:   Rendered sessions/new.html.erb within layouts/application (25.4ms)
2012-05-29T02:57:15+00:00 app[web.1]: Completed 500 Internal Server Error in 27ms
2012-05-29T02:57:15+00:00 app[web.1]: 
2012-05-29T02:57:15+00:00 app[web.1]: ActionView::Template::Error (twitter_64.png isn't precompiled):
2012-05-29T02:57:15+00:00 app[web.1]:     25: <div id="auths">
2012-05-29T02:57:15+00:00 app[web.1]:     27:   <a href="/auth/twitter" class="provider">
2012-05-29T02:57:15+00:00 app[web.1]:     26:   <h2>Or sign in through one of these:</h2>
2012-05-29T02:57:15+00:00 app[web.1]:     28:     <%= image_tag "twitter_64.png", :size => "64x64", :alt => "Twitter" %>Twitter</a>

Interestingly, I have images on other pages that show just fine. Don't know why some images wouldn't work, but some would...

解决方案

First, be sure you have this set as well:

config.assets.initialize_on_precompile = false

If that doesn't work, it's worth trying to manually run the precompile task before building the slug; I think there are subtle differences when done this way:

RAILS_ENV=production bundle exec rake assets:precompile

Last, it's not a solution, but if all else fails, a temporary workaround would be to set

config.assets.compile = true

这篇关于Heroku / Ruby-on-Rails错误:图像不能预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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