Define method on activerecord relation
ruby-on-rails
Solution
Create a `self.summed_values` method directly in the transaction model.
Problem
I want to define a custom method on an activerecord relation, eg: ``` Transaction.all.summed_values ``` A simple example would be where `summed_values` should evaluate `sum(:value)` on the relation. Where should I define the method `summed_values`? Looks like it should be on `ActiveRecord::Relation`. If it should be directly there, which file should I put it in? Also, if this new method only has meaning for `Transaction`s, is there any way to tell rails to only define this method for `ActiveRecord::Relation`s that consist of `Transaction`s?