Project

General

Profile

Download (914 Bytes) Statistics
| Branch: | Tag: | Revision:
b689e231 Marc Dequènes (Duck)
class Artwork < ActiveRecord::Base
belongs_to :artwork_set
belongs_to :artwork_group
belongs_to :artwork_size
belongs_to :artwork_condition
belongs_to :artwork_placement_reason
9f47d0c7 Marc Dequènes (Duck)
has_many :artwork_step_images, :order => "date ASC, id DESC"
70e65017 Marc Dequènes (Duck)
has_and_belongs_to_many :artwork_supports, :order => "name ASC"
3807b362 Marc Dequènes (Duck)
has_and_belongs_to_many :artwork_materials, :order => "name ASC"
b689e231 Marc Dequènes (Duck)
3807b362 Marc Dequènes (Duck)
validates_presence_of :title, :artwork_size_id, :artwork_condition_id
b689e231 Marc Dequènes (Duck)
validates_uniqueness_of :title
validates_length_of :title, :within => 1..256, :allow_blank => true
validates_length_of :placement_location, :within => 1..256, :allow_blank => true
3807b362 Marc Dequènes (Duck)
validates_associated :artwork_set, :artwork_group, :artwork_size, :artwork_condition
b689e231 Marc Dequènes (Duck)
before_save {|model| model.artwork_group = nil if model.artwork_set.nil? }

def image
return nil if self.artwork_step_images.empty?
self.artwork_step_images.last
end
end