Project

General

Profile

Download (1.17 KB) 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, position ASC, id DESC"
has_and_belongs_to_many :artwork_supports, :order => "name ASC"
has_and_belongs_to_many :artwork_materials, :order => "name ASC"
has_and_belongs_to_many :tags, :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

def full_title
str = ""
str += self.artwork_set.name unless artwork_set.nil?
str += " :: " + self.artwork_group.name unless artwork_group.nil?
str += " :: " unless str == ""
str += self.title
end
end
(1-1/13)