Created
November 9, 2011 12:57
-
-
Save jcalvert/1351347 to your computer and use it in GitHub Desktop.
pet image snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir.glob('/mnt/smb/images/pp_uploads/*').each do |glob| | |
hid = glob.split("/").last | |
next unless hid == "2882" | |
Dir.glob("#{glob}/*").each do |cglob| | |
client_id=cglob.split("/").last | |
Dir.glob("#{cglob}/*").each do |plob| | |
patient_id =plob.split("/").last | |
if(Patient.where(:id => patient_id).nil? || Patient.where(:id => patient_id).empty?) | |
next | |
end | |
patient = Patient.where(:id => patient_id).first | |
images = PetImage.find_all_by_pid("#{patient.hid}-#{patient.client.id}-#{patient.id}", :consistent_read=>true) | |
Dir.glob("#{plob}/*").each do |piclob| | |
picname= piclob.split("/").last | |
@pet_image = PetImage.new({:pet_record => patient.pet_record_img, :animal => patient, :idcard_img => patient.idcard_img, :file => File.new(piclob)}) | |
@pet_image.skip_validation=true | |
@pet_image.save | |
p 'SAVED! ',@pet_image.errors | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment