Commit 18ae6db048b699f04995b0607fa6c32d41ab0f9c
1 parent
88dba088
Exists in
master
and in
28 other branches
Default inject value to 0
Showing
1 changed file
with
2 additions
and
1 deletions
Show diff stats
app/models/product.rb
| 1 | class Product < ActiveRecord::Base | 1 | class Product < ActiveRecord::Base |
| 2 | + | ||
| 2 | belongs_to :enterprise | 3 | belongs_to :enterprise |
| 3 | has_one :region, :through => :enterprise | 4 | has_one :region, :through => :enterprise |
| 4 | validates_presence_of :enterprise | 5 | validates_presence_of :enterprise |
| @@ -163,7 +164,7 @@ class Product < ActiveRecord::Base | @@ -163,7 +164,7 @@ class Product < ActiveRecord::Base | ||
| 163 | 164 | ||
| 164 | def total_production_cost | 165 | def total_production_cost |
| 165 | return inputs_cost if price_details.empty? | 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 | end | 168 | end |
| 168 | 169 | ||
| 169 | def price_described? | 170 | def price_described? |