'No route matches' with paperclip and S3 on Heroku

谁都会走 提交于 2019-12-11 12:58:15

问题


Setting up paperclip to use S3 on my local dev system was a snap. However, I am not able to get it to work on Heroku.

The file uploads successfully:

[paperclip] Saving attachments.
[paperclip] saving photos/2/small.jpg
[paperclip] saving photos/2/original.jpg

However, views that try to link to the upload get a routing error:

ActionController::RoutingError (No route matches "/photos/small/missing.png" with {:method=>:get}):

Notice how it is using 'missing' for the file name and is using '.png' for the extension even though the file is a '.jpg'.

I have tried numerous combinations of the :url and :path options with has_attached_file according the various blog posts and tutorials I have found (including Heroku's docs), but none seem to work.

What are the correct steps to use paperclip with S3 on Heroku?


回答1:


Found the problem: needed to update the database.

heroku rake:db:migrate
heroku restart

I had done what I thought would have accomplished the same thing already: heroku rake db:schema:load, but perhaps that doesn't work or something went wrong in the process.

Anyhow, doing that, along with removing the calls to attr_accessor as suggested on another blog, solved the problem.




回答2:


I just had this exact same problem. Ran fine in dev, uploaded files to s3 in prod but wouldn't show the URL for uploaded images. Running

heroku restart

was what fixed it. No need to run db:migrate (unless, of course, you need to migrate the database).

Thanks for the info!




回答3:


Can you paste the code from your form please? I'm guessing that you have forgotten to add :html => {:multipart => true}) to the form_for tag



来源:https://stackoverflow.com/questions/3575812/no-route-matches-with-paperclip-and-s3-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!