Displaying 1 result from an estimated 1 matches for "roles_group".
Did you mean:
roles_groups
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
...oles
end
TABLES:
users
rights
roles
rights_roles (habtm join table)
roles_users (habtm join table)
All fairly standard stuff.
As my application has evolved I wish to add roles to other things as
well such as groups of users. What I don''t want is to have to create
another join table roles_groups.
I think this can be re-factored using polymorphic associations like so.
NEW MODEL CLASSES:
class User < ActiveRecord::Base
has_many :responsibilities, :as => :roleable
has_many :roles, :through => : responsibilities
end
class Group < ActiveRecord::Base
has_many :res...