ruby on rails - Defining methods on the activerecord relationship
I want to define a custom method on an activerecord relation, eg:
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
Transactions, is there any way to tell rails to only define this method for
ActiveRecord::Relations that consist of
Leave a Reply
- ruby on rails - How to return an empty activerecord relationship?
- Ruby on rails activerecord scope and class methods
- ruby on rails - Timestamp of the relationship between habtm and activerecord
- Defining methods in rails migration
- ruby on rails - What is the difference between the build and create methods in an activerecord relationship?
- More similar questions >>