From 323f7cde52442b492a409c45237296d1adfe9fa3 Mon Sep 17 00:00:00 2001 From: Hugo Melo Date: Fri, 6 Sep 2013 16:39:42 -0300 Subject: [PATCH] Allow toggle of name uniqueness on subtypes --- app/models/product.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/product.rb b/app/models/product.rb index 9bc40d4..62e8622 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -32,7 +32,8 @@ class Product < ActiveRecord::Base acts_as_having_settings :field => :data - validates_uniqueness_of :name, :scope => :profile_id, :allow_nil => true + validates_uniqueness_of :name, :scope => :profile_id, :allow_nil => true, :if => :validate_uniqueness_of_column_name? + validates_presence_of :product_category_id validates_associated :product_category @@ -235,4 +236,10 @@ class Product < ActiveRecord::Base delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise + protected + + def validate_uniqueness_of_column_name? + true + end + end -- libgit2 0.21.2