-
Notifications
You must be signed in to change notification settings - Fork 0
/
print.rb
29 lines (26 loc) · 785 Bytes
/
print.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# == Schema Information
#
# Table name: prints
#
# id :bigint not null, primary key
# serial_number :integer
# format :string
# artwork_id :bigint not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Print < ApplicationRecord
FORMATS = %w[
18x24
30x40
50x60
]
belongs_to :artwork
has_many :listings, dependent: :destroy
scope :small, -> { where(format: "18x24") }
scope :medium, -> { where(format: "30x40") }
scope :large, -> { where(format: "50x60") }
scope :posters, -> { joins(:artwork).merge(Artwork.posters) }
scope :photos, -> { joins(:artwork).merge(Artwork.photos) }
scope :illustrations, -> { joins(:artwork).merge(Artwork.illustrations) }
end