Commit 1af7590f0b7eabeae5c3f5903317f9de316eacec

Authored by Braulio Bhavamitra
Committed by Daniela Feitosa
1 parent 2e90d757

Fix use of production cost in product search

app/models/price_detail.rb
@@ -4,9 +4,13 @@ class PriceDetail < ActiveRecord::Base @@ -4,9 +4,13 @@ class PriceDetail < ActiveRecord::Base
4 validates_presence_of :product_id 4 validates_presence_of :product_id
5 5
6 belongs_to :production_cost 6 belongs_to :production_cost
7 - validates_presence_of :production_cost_id 7 + validates_presence_of :production_cost
8 validates_uniqueness_of :production_cost_id, :scope => :product_id 8 validates_uniqueness_of :production_cost_id, :scope => :product_id
9 9
  10 + def name
  11 + production_cost.name
  12 + end
  13 +
10 def price 14 def price
11 self[:price] || 0 15 self[:price] || 0
12 end 16 end
app/models/production_cost.rb
@@ -5,4 +5,5 @@ class ProductionCost < ActiveRecord::Base @@ -5,4 +5,5 @@ class ProductionCost < ActiveRecord::Base
5 validates_presence_of :name 5 validates_presence_of :name
6 validates_length_of :name, :maximum => 30, :allow_blank => true 6 validates_length_of :name, :maximum => 30, :allow_blank => true
7 validates_uniqueness_of :name, :scope => [:owner_id, :owner_type] 7 validates_uniqueness_of :name, :scope => [:owner_id, :owner_type]
  8 +
8 end 9 end
app/views/search/_product.rhtml
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 <% if product.price_described? %> 29 <% if product.price_described? %>
30 <% title = (product.inputs + product.price_details).map{ |i| 30 <% title = (product.inputs + product.price_details).map{ |i|
31 '<div class="search-product-input-dots-to-price">' + 31 '<div class="search-product-input-dots-to-price">' +
32 - '<div class="search-product-input-name">' + i.product_category.name + '</div>' + 32 + '<div class="search-product-input-name">' + i.name + '</div>' +
33 price_span(i.price, :class => 'search-product-input-price') + 33 price_span(i.price, :class => 'search-product-input-price') +
34 '</div>' }.join('') %> 34 '</div>' }.join('') %>
35 <%= link_to_function _("Open Price"), '', :title => title, :class => "search-product-price-details" %> 35 <%= link_to_function _("Open Price"), '', :title => title, :class => "search-product-price-details" %>