add Label validations; add attr_accessible

This commit is contained in:
Alexander Machehin 2014-11-25 01:30:11 +05:00
parent c19983b835
commit 8cf44dfa07
1 changed files with 4 additions and 1 deletions

View File

@ -4,7 +4,10 @@ class Label < ActiveRecord::Base
belongs_to :project belongs_to :project
validates :name, uniqueness: { scope: :project_id } validates :name, uniqueness: { scope: :project_id }
validates :name, :color, presence: true validates :name, length: { in: 1..20 }
validates :color, presence: true
validates :color, format: { with: /\A([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, message: I18n.t('layout.issues.invalid_labels') } validates :color, format: { with: /\A([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, message: I18n.t('layout.issues.invalid_labels') }
attr_accessible :name, :color
end end