Skip to content

Instantly share code, notes, and snippets.

@rubypanther
Created February 3, 2010 05:57
Show Gist options
  • Save rubypanther/293368 to your computer and use it in GitHub Desktop.
Save rubypanther/293368 to your computer and use it in GitHub Desktop.
class Photo
def photo_filename= filename
if (self.photo = File.read(filename) rescue nil)
save!
end
end
end
# ...
task :photos => :environment do
Photo.find_each(:conditions => {:photo_file_name => nil}) { |p|
p.photo_filename = "../flygfotohistoria_old/public/assets/motifs/original/#{p.old_id}.jpg"
puts p.id
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment