rosa-build/app/models/label.rb

12 lines
399 B
Ruby
Raw Permalink Normal View History

2012-02-21 20:28:04 +00:00
class Label < ActiveRecord::Base
2014-01-21 04:51:49 +00:00
has_many :labelings, dependent: :destroy
has_many :issues, through: :labelings
2012-02-23 14:48:31 +00:00
belongs_to :project
2012-02-20 18:41:40 +00:00
2014-03-11 12:40:44 +00:00
validates :name, uniqueness: { scope: :project_id }
validates :name, length: { in: 1..20 }
validates :color, presence: true
2014-03-11 12:40:44 +00:00
validates :color, format: { with: /\A([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, message: I18n.t('layout.issues.invalid_labels') }
2012-02-20 18:41:40 +00:00
end