Skip to content

Instantly share code, notes, and snippets.

@osulyanov
Created January 28, 2013 06:45
Show Gist options
  • Save osulyanov/4653521 to your computer and use it in GitHub Desktop.
Save osulyanov/4653521 to your computer and use it in GitHub Desktop.
Move existing Paperclip attachments to a new path Case in: lib/tasks/copy_paperclip_data.rb And run: rake copy_paperclip_data
desc "Copy paperclip data"
task :copy_paperclip_data => :environment do
@users = User.find :all
@users.each do |user|
unless user.image_file_name.blank?
filename = Rails.root.join('public', 'system', 'images', user.id.to_s, 'original', user.image_file_name)
if File.exists? filename
image = File.new filename
user.image = image
user.save
image.close
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment