Guest User

Untitled

a guest
Jul 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. class Photo < ActiveRecord::Base
  2. belongs_to :resort
  3. acts_as_list :scope => :resort
  4.  
  5. default_scope :order => 'position'
  6.  
  7. has_attached_file :data,
  8. :styles => { :original => '600x600>', :small => '200x200', :tiny => '100x100', :thumb => '64x64#', :iphone_thumb => '57x57#' }
  9.  
  10. validates_attachment_presence :data
  11. validates_attachment_content_type :data,
  12. :content_type => ['image/jpeg', 'image/jpg']
  13.  
  14. validates_attachment_size :data, :in => 0..3000.kilobytes
  15.  
  16. #Add class method in Photo model
  17. def self.destroy_pics(resort, photos)
  18. Photo.find(photos, :conditions => {:resort_id => resort}).each(&:destroy)
  19. end
  20.  
  21. end
Add Comment
Please, Sign In to add comment