On Apr 2, 11:59 am, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> 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

Hi Fred thnaks for your time.

I thought that I had created a class method in the (phonecall class) .
Do you mean in the array class? And how do I do that. Is it not
possibl;e to create methods in the phonecall model file that act upon
a collection(array) of that object or do they have to be acting only
on a single instance of that object.

Once again thanks for your time.
--~--~---------~--~----~------------~-------~--~----~
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