From 18ae6db048b699f04995b0607fa6c32d41ab0f9c Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Thu, 6 Sep 2012 08:31:56 -0300 Subject: [PATCH] Default inject value to 0 --- app/models/product.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/product.rb b/app/models/product.rb index 216eae8..8d910e7 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,4 +1,5 @@ class Product < ActiveRecord::Base + belongs_to :enterprise has_one :region, :through => :enterprise validates_presence_of :enterprise @@ -163,7 +164,7 @@ class Product < ActiveRecord::Base def total_production_cost return inputs_cost if price_details.empty? - inputs_cost + price_details.map(&:price).inject { |sum,price| sum + price } + inputs_cost + price_details.map(&:price).inject(0){ |sum,price| sum + price } end def price_described? -- libgit2 0.21.2