From 9284038dbef5153dac40eda14f1685a72efe1d1a Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Tue, 12 Aug 2014 14:16:25 +0200 Subject: Add, delete labels via API --- app/models/label.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'app/models/label.rb') diff --git a/app/models/label.rb b/app/models/label.rb index ce982579675..b8dc11a5245 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -7,13 +7,14 @@ class Label < ActiveRecord::Base validates :project, presence: true # Dont allow '?', '&', and ',' for label titles - validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ } + validates :title, + presence: true, + format: { with: /\A[^&\?,&]*\z/ }, + uniqueness: true scope :order_by_name, -> { reorder("labels.title ASC") } - def name - title - end + alias_attribute :name, :title def open_issues_count issues.opened.count -- cgit v1.2.1