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