Hi Matt, Thanks for your time. I thought that by putting my total_cost method in the phonecall model that I was doing exactly that.
I appreciate that I can use the view shortcut so thanks for that tip. I do need to understand how to create methods that act upon an array of objects both in this instance and obviousley for my future understanding of this subject. On Apr 2, 12:12 pm, Matthew MacLeod <m...@theskinny.co.uk> wrote: > On 2 Apr 2009, at 11:59, Frederick Cheung wrote: > > >> In my controller I am finding the @phonecalls > >> And in my view I want to say @phoncalls.total_cost > > > The easiest way is probably to create a class method that takes as an > > argument the array and returns the total cost. > > You could also run in your view e.g. @phonecalls.sum { |p| p.cost } > > -Matt --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---