This would be cool to have in Rails.
class User < ActiveRecord::Base
has_many :roles
end
class Role < ActiveRecord::Base
belongs_to :user
belongs_to :rolable, :polymorphic => true
end
class Student < ActiveRecord::Base
has_one :role, :as => :rolable
has_one :user, :through => :rolable # * This is not possible
yet in Rails (I think).
end
class Teacher < ActiveRecord::Base
has_one :role, :as => :rolable
has_one :user, :through => :rolable # * This is not possible
yet in Rails.
end
Then be able to say:
@student.user # Instead of having to say @student.role.user
Or even better be able to say @student.email when `email` was a column
of User but not Student.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---