Skip to content

Instantly share code, notes, and snippets.

@sunkencity
Created April 18, 2011 09:36
Show Gist options
  • Save sunkencity/925082 to your computer and use it in GitHub Desktop.
Save sunkencity/925082 to your computer and use it in GitHub Desktop.
Rails:: Quick and Dirty move attachments on S3 from one path to another with paperclip.
class Paperclip::Attachment
def save
flush_deletes
oldpath = @path
@path = '/:attachment/:id/:style/:filename'
puts 'patching the path...'
flush_writes
@path = oldpath
@dirty = false
true
end
end
Model.all.map { |p| p.attachment_name.reprocess! }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment