Project

General

Profile

Download (905 Bytes) Statistics
| Branch: | Tag: | Revision:

root / app / models / artwork.rb @ 3807b362

1
class Artwork < ActiveRecord::Base
2
  belongs_to :artwork_set
3
  belongs_to :artwork_group
4
  belongs_to :artwork_size
5
  belongs_to :artwork_condition
6
  belongs_to :artwork_placement_reason
7
  has_many :artwork_step_images, :order => "date ASC"
8
  has_and_belongs_to_many :artwork_supports, :order => "name ASC"
9
  has_and_belongs_to_many :artwork_materials, :order => "name ASC"
10

    
11
  validates_presence_of :title, :artwork_size_id, :artwork_condition_id
12
  validates_uniqueness_of :title
13
  validates_length_of :title, :within => 1..256, :allow_blank => true
14
  validates_length_of :placement_location, :within => 1..256, :allow_blank => true
15
  validates_associated :artwork_set, :artwork_group, :artwork_size, :artwork_condition
16

    
17
  before_save {|model| model.artwork_group = nil if model.artwork_set.nil? }
18

    
19
  def image
20
    return nil if self.artwork_step_images.empty?
21
    self.artwork_step_images.last
22
  end
23
end
(1-1/12)