From 1af7590f0b7eabeae5c3f5903317f9de316eacec Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Wed, 8 Aug 2012 18:39:51 +0000 Subject: [PATCH] Fix use of production cost in product search --- app/models/price_detail.rb | 6 +++++- app/models/production_cost.rb | 1 + app/views/search/_product.rhtml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) 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| '
' + - '
' + i.product_category.name + '
' + + '
' + i.name + '
' + price_span(i.price, :class => 'search-product-input-price') + '
' }.join('') %> <%= link_to_function _("Open Price"), '', :title => title, :class => "search-product-price-details" %> -- libgit2 0.21.2