Commit 18ae6db048b699f04995b0607fa6c32d41ab0f9c

Authored by Braulio Bhavamitra
1 parent 88dba088

Default inject value to 0

Showing 1 changed file with 2 additions and 1 deletions   Show diff stats
app/models/product.rb
1 1 class Product < ActiveRecord::Base
  2 +
2 3 belongs_to :enterprise
3 4 has_one :region, :through => :enterprise
4 5 validates_presence_of :enterprise
... ... @@ -163,7 +164,7 @@ class Product &lt; ActiveRecord::Base
163 164  
164 165 def total_production_cost
165 166 return inputs_cost if price_details.empty?
166   - inputs_cost + price_details.map(&:price).inject { |sum,price| sum + price }
  167 + inputs_cost + price_details.map(&:price).inject(0){ |sum,price| sum + price }
167 168 end
168 169  
169 170 def price_described?
... ...