Commit 323f7cde52442b492a409c45237296d1adfe9fa3

Authored by Hugo Melo
Committed by Braulio Bhavamitra
1 parent 24c90b37

Allow toggle of name uniqueness on subtypes

Showing 1 changed file with 8 additions and 1 deletions   Show diff stats
app/models/product.rb
@@ -32,7 +32,8 @@ class Product < ActiveRecord::Base @@ -32,7 +32,8 @@ class Product < ActiveRecord::Base
32 32
33 acts_as_having_settings :field => :data 33 acts_as_having_settings :field => :data
34 34
35 - validates_uniqueness_of :name, :scope => :profile_id, :allow_nil => true 35 + validates_uniqueness_of :name, :scope => :profile_id, :allow_nil => true, :if => :validate_uniqueness_of_column_name?
  36 +
36 validates_presence_of :product_category_id 37 validates_presence_of :product_category_id
37 validates_associated :product_category 38 validates_associated :product_category
38 39
@@ -235,4 +236,10 @@ class Product < ActiveRecord::Base @@ -235,4 +236,10 @@ class Product < ActiveRecord::Base
235 236
236 delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise 237 delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise
237 238
  239 + protected
  240 +
  241 + def validate_uniqueness_of_column_name?
  242 + true
  243 + end
  244 +
238 end 245 end