I have a db Orders with fields qty and amount, and another linked db
Person that has many Orders. I've been using this to sum all of the
products of qty and amount:
Person.find( person ).orders.inject( 0 ){ |sum, order| sum +
( order.qty * order.amount ) }
Is there another/better way to do this in ActiveRecord?
Many TIA,
Craig
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---