Found it:
proxy_owner
User.first.events.upcoming
def upcoming
case self.proxy_owner.class
when User
# do stuff for User
when Group
# do stuff for groups
else
end
end
On Oct 20, 2:30 pm, twoism
<signalsta...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Is there away get a collections parent model from within the
> collection itself? Where the collection looks like this:
>
> User.first.events.upcoming
> or
> Group.first.events.upcoming.
>
> If the upcoming method is in a mix-in that is shared by two different
> models how could you find what the parent model is (Group or User)?
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---