You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
krismeister edited this page May 25, 2013
·
6 revisions
After changing attachment's :path setting images need to be recreated. You can use the following rake task
# Assuming you had a model like this## class Post# has_attached_file :image, :path => ":rails_root/public/system/:attachment/:id/:style/:filename"# endnamespace:paperclipdodesc"Recreate attachments and save them to new destination"task:move_attachments=>:environmentdoPost.find_eachdo |post|
unlesspost.image_file_name.blank?filename=Rails.root.join('public','system','images',post.id.to_s,'original',post.image_file_name)ifFile.exists?filenameputs"Re-saving image attachment #{post.id} - #{filename}"image=File.newfilenamepost.image=imagepost.save# if there are multiple styles, you want to recreate them :post.image.reprocess!image.closeendendendendend