Commit 8f42ea6fdc629a43195adc4b367b2b3115b7d152

Authored by Daniela Feitosa
1 parent 5ad46e23

Calling method instead of calculating cost on view

(ActionItem2111)
app/models/input.rb
... ... @@ -59,9 +59,4 @@ class Input < ActiveRecord::Base
59 59 return 0 if self.amount_used.blank? || self.price_per_unit.blank?
60 60 self.amount_used * self.price_per_unit
61 61 end
62   -
63   - def cost
64   - return 0 if self.amount_used.blank? || self.price_per_unit.blank?
65   - self.amount_used * self.price_per_unit
66   - end
67 62 end
... ...
app/views/catalog/index.rhtml
... ... @@ -59,7 +59,7 @@
59 59 <% product.inputs.each do |i| %>
60 60 <div class="search-product-input-dots-to-price">
61 61 <div class="search-product-input-name"><%= i.product_category.name %></div>
62   - <%= price_span i.price_per_unit * i.amount_used, :class => 'search-product-input-price' %>
  62 + <%= price_span i.cost, :class => 'search-product-input-price' %>
63 63 </div>
64 64 <% end %>
65 65 </div>
... ...