From 8cf44dfa0734cb5928f55aa88c29f1b3601d68a3 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 25 Nov 2014 01:30:11 +0500 Subject: [PATCH] add Label validations; add attr_accessible --- app/models/label.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/label.rb b/app/models/label.rb index f70bdb818..91871f97c 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -4,7 +4,10 @@ class Label < ActiveRecord::Base belongs_to :project 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') } + attr_accessible :name, :color end