This error trips up a lot of people when they start using Heroku, me included!
The reason that you can't store files locally on Heroku is that this just isn't how Heroku works. Heroku takes a copy of your git repository and bundles it up into a "slug" which then gets run on their servers. Anything outside your slug (i.e. that's not stored within your git repo) will be lost when the dyno (virtual UNIX instance) restarts.
You can see this by firing up a console with heroku run rails c
and creating and saving a new file using Ruby's File
object. The new file will save correctly, and you can do things like require
it or read from it, but if you close and reopen the console window, the file will have disappeared.
So if you want to store files that are being uploaded through a form, you need to use an external storage service. I like Amazon S3 as it's very simple to integrate with Heroku using Paperclip, as the links in the other answer mention.