Jake Boxer wrote: > After a lot of careful research, I've made the decision to go with > Authlogic ( http://github.com/binarylogic/authlogic ) for > authentication in my app. > > I currently have a User model (which "acts_as_authentic" in > Authlogic). However, my app is going to have multiple user types > ("Teacher", "Student", and potentially "Teacher's Assistant"). For the > moment, they'll all be mutually exclusive; a user can't be both a > Teacher's Assistant and a Student, for example. > > Currently, I'm planning on creating separate models for each of these > (Teacher, Student, TA). They'll each "belongs_to" a User, and a user > will "has_one" of each. This way, I'll be able to put any common > methods/fields in User, and any exclusive methods/fields in the model > it belongs in. > > I'm very new to Ruby (and, by association, to Rails). Does this sound > like a reasonable way to do this?
No. If you want several kinds of user models, make them *inherit* from User. However, you probably only want one User model with a Role field. Then use something like rails_authorization or acl9 if you want role-based security. > Does it follow "the Ruby/Rails way"? No, to the extent that it doesn't follow proper object-oriented design owing to misuse of associations as I outlined above. > Or is there a common pattern for doing this in Rails that I don't know > about? See above. In general, if X is a kind of Y, then X should be a subclass of Y. > > Thank you very much in advance > -Jake Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 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 -~----------~----~----~----~------~----~------~--~---