On Jul 12, 3:43 pm, pepe <[email protected]> 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 [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