Displaying 2 results from an estimated 2 matches for "groupables".
Did you mean:
groupable
2006 Jul 26
3
Polymorphic Association with Single Table Inheritance?
...lumn)
has_many :memberships, :as => :groupable
has_many :groups, :through => :memberships
Membership
belongs_to :groupable, :polymorphic => true
belongs_to :group, :polymorphic => true
Group (table with ''type'' column)
has_many :memberships, :as => :group
has_many :groupables, :through => :memberships
And the inherited tables:
User < Groupable
has_many :user_groups, :through => :memberships
UserGroup < Group
has_many :users, :through => :memberships
Setting up an user, a membership and an user_group
works, but it throws an exception on accessing
us...
2006 Aug 16
0
Polymorphic Associations and grouping users and projects
Hi all,
In my app I would like to create user groups in my admin. Currently I
have the following models and associations that facilitate this.
class User < ActiveRecord::Base
has_many :memberships
has_many :groups, :through => :memberships
end
class Membership < ActiveRecord::Base
belongs_to :group
belongs_to :user
end
class Group < ActiveRecord::Base
has_many