clarion/app/models/track.rb

21 lines
515 B
Ruby
Raw Normal View History

class Track < ActiveRecord::Base
include PropositionAccepting
belongs_to :conference
has_many :events, through: :propositions, source: :proposable, source_type: Event
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
translates :name, :description
def color=(hex_triplet)
write_attribute :color, hex_triplet.gsub(/\A#/,'') if hex_triplet
end
2014-10-14 18:27:28 +03:00
def color
"##{read_attribute :color}"
end
end