Ruby on Rails Thursday, December 30, 2010

On Thursday, December 30, 2010 1:38:18 PM UTC-5, Rails beginner wrote:

Hello

I have a problem. I cant figure out how to solve this authentication
problem with devise and i dont know if i should use a polymorphic
association in the models or STI.

I want to have 2 sign up pages. One for Teacher and one for Student. I
want the User table to store the login information(email,
password ...).

In that case, you want to use STI.

To get that working, your user class would inherit from ActiveRecord::Base, but your Student and Teacher class would inherit from User. No associations necessary.

class User < ActiveRecord::Base
class Student < User
class Teacher < User

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment