On 2 Apr 2009, at 11:35, Rick wrote:

>
> Hi I am learning rails and have hit a bit of a wall.
>
> I have created methods previousley that work fine on a single object.
> However in my latest project I am trying to calculate the total cost
> of a group of phonecalls and I am having difficulty creating a method
> to calculate this. I have a phonecall model and phonecall has a cost
> attribute.
>
> In my controller I am finding the @phonecalls
> And in my view I want to say @phoncalls.total_cost
>
>
> end

You've defined a total_cost method on the PhoneCall class, but you're  
trying to call it on an instance of Array (that just happens to  
contain phone calls)
The easiest way is probably to create a class method that takes as an  
argument the array and returns the total cost.

Fred


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to