class ArtworkImage < ActiveRecord::Base
  belongs_to :artwork
  
  mount_uploader :image, ImageUploader
  
  before_destroy do 
    if self.artwork.artwork_image_id = self.id
      
      self.artwork.artwork_image = self.artwork.artwork_images.where("id NOT IN ( ? )",self.id).first
      self.artwork.save
    end
    
  end
end
