From 8f42ea6fdc629a43195adc4b367b2b3115b7d152 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Fri, 30 Dec 2011 19:09:17 -0200 Subject: [PATCH] Calling method instead of calculating cost on view --- app/models/input.rb | 5 ----- app/views/catalog/index.rhtml | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/models/input.rb b/app/models/input.rb index 92e8e3c..541fbc4 100644 --- a/app/models/input.rb +++ b/app/models/input.rb @@ -59,9 +59,4 @@ class Input < ActiveRecord::Base return 0 if self.amount_used.blank? || self.price_per_unit.blank? self.amount_used * self.price_per_unit end - - def cost - return 0 if self.amount_used.blank? || self.price_per_unit.blank? - self.amount_used * self.price_per_unit - end end diff --git a/app/views/catalog/index.rhtml b/app/views/catalog/index.rhtml index 55109cc..416bbe1 100644 --- a/app/views/catalog/index.rhtml +++ b/app/views/catalog/index.rhtml @@ -59,7 +59,7 @@ <% product.inputs.each do |i| %>
<%= i.product_category.name %>
- <%= price_span i.price_per_unit * i.amount_used, :class => 'search-product-input-price' %> + <%= price_span i.cost, :class => 'search-product-input-price' %>
<% end %> -- libgit2 0.21.2