root/app/models/artwork.rb @ 15ec0432
b689e231 | Marc Dequènes (Duck) | class Artwork < ActiveRecord::Base
|
|
belongs_to :artwork_set
|
|||
belongs_to :artwork_group
|
|||
belongs_to :artwork_material
|
|||
belongs_to :artwork_size
|
|||
belongs_to :artwork_condition
|
|||
belongs_to :artwork_placement_reason
|
|||
has_many :artwork_step_images, :order => "date ASC"
|
|||
has_and_belongs_to_many :techniques, :order => "name ASC"
|
|||
validates_presence_of :title, :artwork_material_id, :artwork_size_id, :artwork_condition_id
|
|||
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
|
|||
validates_associated :artwork_set, :artwork_group, :artwork_material, :artwork_size, :artwork_condition
|
|||
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
|