title: nil can't be coerced into Float
body: <p>I'm coding a billing system with RoR 3.2.11.</p>
  
  <p>Now I want to calculate the total amount of the bill. For that, I designed the Model like that:</p>
  
  <pre><code>class Bill &lt; ActiveRecord::Base
    belongs_to :customer
    has_many :bill_items, :dependent =&gt; :destroy
    has_many :articles, :through =&gt; :bill_items
    attr_accessible :date, :discount, :state, :category, :customer_id, :bill_items_attributes
    accepts_nested_attributes_for :bill_items, :reject_if =&gt; lambda { |a| a[:count].blank? }, :allow_destroy =&gt; true
  
    def total
       bill_items.inject(0) { |acc, bill_items| acc + (bill_items.count * bill_items.article.price) } - discount
    end
  end
  </code></pre>
  
  <p>That works great, if something is store in the db. If the "bill_item" is empty, I get the following message:</p>
  
  <pre><code>TypeError in Bills# edit
  nil can't be coerced into Float
  </code></pre>
  
  <p>It would be great, if anybody can halp me with that problem.</p>