athk/bsmi — pull request #13 by andrewmains12 (2012-10-26 03:34:54+00:00)
Title: Profiles

This branch implements different user types as models which have a one to one relationship with User (this should be perhaps renamed to something like 'Profile'). The User model contains all state needed for logging in (contact info etc). Each user belongs to an "owner". At the moment, owners can be one of [Student, MentorTeacher].

To add a new user class, you need to do two things at the moment:

1.
```ruby
#In your new user class,
#Add the polymorphic association
has_one(:user), :as => :owner
```

2.
```ruby
#In User
#Add the new user class to @@user_types
@@user_types = Hash[[MentorTeacher, Student, ].map {|type| [type.name, type]}]

#This isn't ideal; we can probably make it better/more scaleable later.
```

At the moment, users are asked to select their role when they sign up; later we'll probably want to do this with some sort of authentication token, so people can't sign up for something they're not authorized for. This is just for the proof of concept.