How to create a custom method for my rails model
<p>I have a <code>Company</code> model and a <code>Payment</code> model. </p>

<p>For my <code>Company</code> model I whish to create a custom (class/instance?) method that performs a sumproduct of a selected company's associated attributes.</p>

<p>My <code>Company</code>  model:</p>

<pre><code>def total_payments
  self.payments.map { |s| s.value * s.currency }.sum
end
</code></pre>

<p>However if I run <code>Company.first.total_payments</code> it gives me a <code>no_method_error</code>.</p>

<p>How to I properly define my method?</p>