Hi Fred, Just [re]discovered about STI right after my answer to the first reply. I made the necessary changes to the users table, tried it and it worked quite fine when I fixed the kinks trying to access the value with user.type. Once I figured that one out everything worked as expected.
Thanks. Pepe On Jul 12, 4:35 pm, Frederick Cheung <frederick.che...@gmail.com> wrote: > On Jul 12, 3:43 pm, pepe <p...@betterrpg.com> wrote: > > > When a user is retrieved for access and functionality validations, I > > re-retrieve the user through the specific user class as in: > > user = User.find(...) > > # The user is found and passes validations. > > # Now I re-retrieve it through the specific user class based in the > > category value. > > user = user.category.capitalize.constantize.find(user.id) if user > > > From that moment on I have the user retrieved through its correct type > > and my associations work wonderfully. > > If you use single table inheritance then User.find(...) would > automatically return an instance of Tenant, Auditor or Admin as > appropriate and you wouldn't need to refetch it. > > Fred > > > > > Is there a better way of making this work? > > > Thanks. > > > Pepe --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---