2014-08-10 20:30:37 +03:00
|
|
|
class Track < ActiveRecord::Base
|
|
|
|
belongs_to :conference
|
2015-08-14 23:40:32 +03:00
|
|
|
has_many :events
|
2014-08-10 20:30:37 +03:00
|
|
|
|
|
|
|
validates :name, presence: true
|
2014-10-14 18:27:28 +03:00
|
|
|
validates :color, presence: true, format: {with: /\A#?[a-f0-9]{6}\z/i}
|
|
|
|
validates :description, presence: true
|
2014-08-10 20:30:37 +03:00
|
|
|
|
2014-09-06 18:18:08 +03:00
|
|
|
translates :name, :description
|
|
|
|
|
2014-08-10 20:30:37 +03:00
|
|
|
def color=(hex_triplet)
|
2019-04-28 21:10:54 +03:00
|
|
|
write_attribute :color, hex_triplet.gsub(/\A#/, "") if hex_triplet
|
2014-08-10 20:30:37 +03:00
|
|
|
end
|
2014-10-14 18:27:28 +03:00
|
|
|
|
|
|
|
def color
|
|
|
|
"##{read_attribute :color}"
|
|
|
|
end
|
2014-08-10 20:30:37 +03:00
|
|
|
end
|