【问题标题】:images precompiled, heroku keeps complaining on some图像预编译,heroku 不断抱怨一些
【发布时间】:2012-07-20 04:53:25
【问题描述】:

我在 /app/assets/images 文件夹中添加了一张图片,logo-small.jpg

然后我将这一行添加到我的视图中

= link_to image_tag('logo-small.jpg'), root_path, :class => 'brand'

然后我预编译,

rake assets:precompile RAILS_ENV=production

git add、git commit 和 git push heroku master。推送有效。

我仍然收到错误

ActionView::Template::Error (logo-small.jpg isn't precompiled):

为什么?

编辑:我尝试了其他图像,它们都很好。 Heroku 的 logo 和 logo-small 有问题,但其他图像没有。 wtf??

【问题讨论】:

  • 你在 heroku 上运行什么堆栈?新的 Cedar 堆栈应该会自动预编译您的资产。如果它较旧,您可能必须在服务器上运行 rake 任务。
  • 雪松。我在 2 天前开设了帐户。
  • 谢谢。你能像下面这样在你的服务器上手动运行assets:precompile吗?

标签: ruby-on-rails heroku production-environment precompiled


【解决方案1】:

如果您在 heroku 的 Cedar 堆栈上,当您推送到 heroku 时,您的资产应该会自动预编译。如果您在该堆栈上并且仍然遇到错误,那将是很高兴知道。

如果您使用的是 Bamboo 堆栈(有点旧,但曾经是默认堆栈),您可以尝试在服务器上运行 rake task 以使其编译您已经推送的资产。

heroku run rake assets:precompile

【讨论】:

  • 我做到了。结果还是一样。
【解决方案2】:

从未发现它是什么。将格式从 jpg 切换为 png 并且可以正常工作。

【讨论】:

  • 除非是照片,否则总是使用 png
  • Png 是无损的。乔希是有损的。照片是有损的好东西。标签图像应使用无损
猜你喜欢
  • 1970-01-01
  • 2011-01-08
  • 2013-04-08
  • 2017-01-17
  • 1970-01-01
  • 1970-01-01
  • 2012-03-28
  • 2016-11-01
  • 1970-01-01
相关资源
最近更新 更多