ActionView :: Template :: Error(未预编译):

时间:2021-06-12 20:41:32

In production (Heroku), I'm getting the following error:

在生产(Heroku)中,我收到以下错误:

Started GET "/articles/1" for 50.134.181.231 at 2012-06-17 00:37:35 +0000
2012-06-17T00:37:35+00:00 app[web.1]: ActionView::Template::Error ( isn't precompiled):
2012-06-17T00:37:35+00:00 heroku[router]: GET wandr.com/articles/1 dyno=web.1 queue=0 wait=0ms service=497ms status=500 bytes=728
2012-06-17T00:37:35+00:00 app[web.1]: 
2012-06-17T00:37:35+00:00 app[web.1]:     74:   = image_tag @article.featured_photo_url(:sm).to_s
2012-06-17T00:37:35+00:00 app[web.1]:     75: 
2012-06-17T00:37:35+00:00 app[web.1]:     77:   = image_tag @article.background_photo_url(:md).to_s
2012-06-17T00:37:35+00:00 app[web.1]:     76: %p
2012-06-17T00:37:35+00:00 app[web.1]:     78: %p
2012-06-17T00:37:35+00:00 app[web.1]:     79:   = image_tag @article.cover_photo_url(:md).to_s
2012-06-17T00:37:35+00:00 app[web.1]:     80: 
2012-06-17T00:37:35+00:00 app[web.1]:   app/views/articles/show.html.haml:77:in `_app_views_articles_show_html_haml__1847247375488199378_48105500'
2012-06-17T00:37:35+00:00 app[web.1]: 
2012-06-17T00:37:35+00:00 app[web.1]:   app/controllers/articles_controller.rb:21:in `show'
2012-06-17T00:37:35+00:00 app[web.1]: 
2012-06-17T00:37:35+00:00 app[web.1]: Processing by ArticlesController#show as HTML
2012-06-17T00:37:35+00:00 app[web.1]:   Rendered articles/show.html.haml within layouts/admin (420.5ms)
2012-06-17T00:37:35+00:00 app[web.1]:   Parameters: {"id"=>"1"}
2012-06-17T00:37:35+00:00 app[web.1]: Completed 500 Internal Server Error in 486ms

I'm running Rails 3.2.6, including actionpack 3.2.6 which I thought had this fix for this issue: https://github.com/rails/rails/commit/6bb86e1f3f7f9e11ee1c056d8742125173ecbce1

我正在运行Rails 3.2.6,包括actionpack 3.2.6,我认为这个问题解决了这个问题:https://github.com/rails/rails/commit/6bb86e1f3f7f9e11ee1c056d8742125173ecbce1

I also tried this: "ActionView::Template::Error ( isn't precompiled)" raised on "image_tag nil"

我也试过这个:“ActionView :: Template :: Error(未预编译)”在“image_tag nil”上引发

Basically, as long as one of the images on this page don't exist, it's throwing this error. If I upload the images, it works fine. Any ideas?

基本上,只要此页面上的某个图像不存在,就会抛出此错误。如果我上传图像,它工作正常。有任何想法吗?

Thanks, --Mark

谢谢, - 马克

1 个解决方案

#1


46  

I assume you're using something like CarrierWave to handle file uploads? You can specify a default image handler in your uploader class:

我假设您使用像CarrierWave这样的东西来处理文件上传?您可以在上传器类中指定默认图像处理程序:

https://github.com/jnicklas/carrierwave#providing-a-default-url

https://github.com/jnicklas/carrierwave#providing-a-default-url

class MyUploader < CarrierWave::Uploader::Base
  def default_url
    "/images/fallback/" + [version_name, "default.png"].compact.join('_')
  end
end

This will output the default image rather than trying to access a non-existent file called "" in the asset pipeline.

这将输出默认图像,而不是尝试访问资产管道中名为“”的不存在的文件。

#1


46  

I assume you're using something like CarrierWave to handle file uploads? You can specify a default image handler in your uploader class:

我假设您使用像CarrierWave这样的东西来处理文件上传?您可以在上传器类中指定默认图像处理程序:

https://github.com/jnicklas/carrierwave#providing-a-default-url

https://github.com/jnicklas/carrierwave#providing-a-default-url

class MyUploader < CarrierWave::Uploader::Base
  def default_url
    "/images/fallback/" + [version_name, "default.png"].compact.join('_')
  end
end

This will output the default image rather than trying to access a non-existent file called "" in the asset pipeline.

这将输出默认图像,而不是尝试访问资产管道中名为“”的不存在的文件。