Search code examples
ruby-on-railsherokuassetsprecompiled

Precompiling uploaded assets


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?


Solution

    • 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 use image_tag, you must pass a complete URL, not just an image name.