预编译上传的资产 [英] Precompiling uploaded assets
问题描述
我有一个用户上传图片的rails 3.1应用程序。我将它们存储在/ assets / images中,因为这是image_tag寻找的路径,而不是public / images。
在开发中一切正常,但我部署到Heroku和它给我这个错误:
ActionView :: Template :: Error(image_name.jpeg未预编译)
处理这种情况的正确方法是什么?有没有办法在上传后编译图像,或者我应该将它们存储在其他地方? p>您不得在Heroku上使用文件系统来存储上传内容。 与上传的图像,因为它假定它正在看文件系统。如果您使用 image_tag
,则必须传递完整的网址,而不仅仅是图片名称。 b
I have a rails 3.1 application where users upload pictures. I am storing them in /assets/images since that is the path image_tag looks for instead of public/images.
Everything works fine in development but I deployed to Heroku and it gives me this error:
ActionView::Template::Error (image_name.jpeg isn't precompiled)
What is the right way to handle such a situation? Is there a way to compile images after uploading or should I store them somewhere else?
You must not use the filesystem on Heroku to store uploads.
You should not use
image_path
with uploaded images, since that assumes it is looking at the filesystem. If you useimage_tag
, you must pass a complete URL, not just an image name.
这篇关于预编译上传的资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!