Project

General

Profile

Download (914 Bytes) Statistics
| Branch: | Tag: | Revision:
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
has_many :artwork_step_images, :order => "date ASC, id DESC"
has_and_belongs_to_many :artwork_supports, :order => "name ASC"
has_and_belongs_to_many :artwork_materials, :order => "name ASC"

validates_presence_of :title, :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_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
(1-1/12)