Forum: Ruby on Rails Get a collections parent model.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
twoism (Guest)
on 2008-10-20 22:31
(Received via mailing list)
Is there away get a collections parent model from within the
collection itself? Where the collection looks like this:

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)?
twoism (Guest)
on 2008-10-20 23:19
(Received via mailing list)
Found it:


def upcoming
  case self.proxy_owner.class
  when User
   # do stuff for User
  when Group
  # do stuff for groups
This topic is locked and can not be replied to.