diff --git a/app/models/price_detail.rb b/app/models/price_detail.rb index 3cde3de..d6a7038 100644 --- a/app/models/price_detail.rb +++ b/app/models/price_detail.rb @@ -4,9 +4,13 @@ class PriceDetail < ActiveRecord::Base validates_presence_of :product_id belongs_to :production_cost - validates_presence_of :production_cost_id + validates_presence_of :production_cost validates_uniqueness_of :production_cost_id, :scope => :product_id + def name + production_cost.name + end + def price self[:price] || 0 end diff --git a/app/models/production_cost.rb b/app/models/production_cost.rb index f1e0025..28cfd01 100644 --- a/app/models/production_cost.rb +++ b/app/models/production_cost.rb @@ -5,4 +5,5 @@ class ProductionCost < ActiveRecord::Base validates_presence_of :name validates_length_of :name, :maximum => 30, :allow_blank => true validates_uniqueness_of :name, :scope => [:owner_id, :owner_type] + end diff --git a/app/views/search/_product.rhtml b/app/views/search/_product.rhtml index 8ae990f..41404aa 100644 --- a/app/views/search/_product.rhtml +++ b/app/views/search/_product.rhtml @@ -29,7 +29,7 @@ <% if product.price_described? %> <% title = (product.inputs + product.price_details).map{ |i| '