Matt Jones wrote in post #975916: > On Jan 18, 6:45pm, skt <[email protected]> wrote: >> >> # relationships and functionality to work on students and grades etc >> end >> >> Searched around but can't find anything on this. It doesn't look like >> I can accomplish this through STI. However I have the Parent and >> Teacher functionality setup through these STI models. What is the best >> way to model/enable this? > > I did this with a pretty gross hack on an app a while back - the roles > were designed to be mutually exclusive, then the client changed their > mind 4+ months in. The trick was to disambiguate the records by > fiddling with the email - in my case, I added the (underscored) role > to the email. So [email protected] who was (for instance) a Parent and a > Teacher would have two records: > > Parent: email_address = '[email protected]' > Teacher: email_address = '[email protected]'
That's a dreadful idea. You're essentially keeping the user from meaningfully pluscoding his e-mail address. > > I had to tweak the code that handled login, and add some callbacks to > keep the records in sync (as well as always de-mangling the emails for > display). > > From the UI side, I added a screen to allow users to switch between > each of the roles; for the app, this made sense as each role had a > somewhat different set of navigation tabs + view permissions. > > Not the cleanest solution, but it beat rewriting everything to > accommodate multiple roles per user. No it didn't. That's a dreadful hack, and you should rip it out and do it right (which would probably have taken no longer...) > > --Matt Jones Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. -- 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.

