On 24 Sep 2008, at 11:00, Sijo Kg wrote:

>
>           But when I call
> sd_ticket
> .add_status_histories_on_convert
> (sd_id,status_id,created_by_id,modified_by_id)
>
>       It works properly  Please tell me why this happens
>

Well it shouldn't be a surprise that calling a class method on an  
instance doesn't work. That's just the way things work. The second  
case is the interesting one. I assume you mean

sd_ticket 
.service_desk_status_histories.add_status_histories_on_convert(...)

The reason this works is because  
sd_ticket.service_desk_status_histories is a proxy. Conceptually it is  
a bit like a scoped version of ServiceDeskStatusHistory (scoped so  
that it belongs to sd_ticket).
For example sd_ticket.service_desk_status_histories.find will only  
find instances of ServiceDeskStatusHistory belonging to that ticket.  
In a similar way class methods are available on this proxy object  
(with_scope is used to scope them to the owner)

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

Reply via email to