Reputation: 91
I am seeing this somehow odd problem (even though I have the feeling I am missing something obvious since I am new to rails). When I upload an image and save a record through activeadmin in heroku everything seems to work fine, the image appears correctly. Some changes later and a push to heroku, the images appear to be gone. As far as i can tell by checking through console and by the generated file paths in my views, there is no change to the columns used by paperclip, but the image seems to be missing from the filesystem. Just a note I am using a free heroku account atm. Any ideas of what I might be doing wrong? Thanks in advance
Upvotes: 1
Views: 963
Reputation: 26528
The Heroku filesystem is not writeable. Even if you save the images in the tmp
directory they will not exist on all Dyno instances and will likely disappear as Dynos are destroyed and created.
You need to save your images to Amazon S3 or another similar storage service.
Upvotes: 1
Reputation: 37507
I'll pre-empt the answer to the question I posed...I suspect you were expecting the Heroku filesystem to work like a normal one however it does not. You need to use an external service to host your images on, something like Amazon S3 works very well.
If you're using Rails 3.1 I presume you are using the Cedar stack - whilst you are able to write to this stacks file system it is LOCAL to the running dyno and not shared across dynos NOR does it persist across dyno restarts or deployments - this explains why you are seeing them until you deploy a change to heroku which restarts your application.
This article http://devcenter.heroku.com/articles/read-only-filesystem#cedar explains it in more detail.
Upvotes: 7