Guest User

Untitled

a guest
Mar 13th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. def batch
  2. if request.post?
  3. images = params[:images]
  4. session[:images_to_tag] = []
  5. images.each do |id, img|
  6. unless img['uploaded_data'].blank?
  7. uploaded_data = params[:images][id].delete(:uploaded_data) # pop off uploaded data
  8.  
  9. image_attributes = params[:images][id].merge(params[:image])
  10. @image = Image.new(image_attributes)
  11. @image_picture = ImagePicture.new(:image_obj => @image)
  12. @image_picture.uploaded_data = uploaded_data
  13. @image.picture = @image_picture
  14. @image.user = @current_user
  15. @image.save!
  16. session[:images_to_tag] << @image.id
  17. end
  18. end
  19.  
  20. flash[:notice] = 'Your image was successfully uploaded.'
  21. session[:image_tagging_job_key] = Image.start_tagging(session[:images_to_tag])
  22. redirect_to :action => 'auto_tagging_progress'
  23. end
  24. rescue ActiveRecord::RecordInvalid
  25. render :action=>'batch'
  26. end
Add Comment
Please, Sign In to add comment