Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Image not Showing on Ruby on Rails app deployed on Heruku

I have a Ruby on Rails application that has some images pulled from the database. They display fine but the moment i deploy new code on heroku, the images not longer show. But on my local machine everything still shows fine. Is there any configuration in heroku that interferes with this.

Thanks in advance.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Did you seed the production database on Heroku with said images and you're sure they are uploaded?

I have uploaded the images from the production url on heroku. After loading, I would check if they display. They display correctly. But if I can deploy a code change on production and check the images again, they no longer display after that. All other data displays fine expect the images. But it only happens after a code change.

It doesn't happen on the development environment though.

2 Answers

J Scott Erickson
J Scott Erickson
11,883 Points

In the past when I've had this sort of issue, its been one of paths to the image. I could be totally off base on that though. Just the first thought that came to my head.

I appreciate the effort that you took to answer my question, I figured out the problem listed below.

It turns out that on every new commit i push to heroku, Heroku removes all the images that are uploaded by the application, except the ones that I have committed myself, this could be the images in the resource files etc.

One way to solve this is to use a separate file storage facility like amazon s3.

Another way would be to directly sore images as BLOB in the database.

Kind Regards,

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Oh, now I remember reading something about this. They also don't like if users of your app upload images to their server and they remove them after some time, so something like Amazon is necessary ;)