I’m trying to build a little Secret Santa application. A User can join
various Secret Santa Groups. In the Group, the User can post
suggestions for other members of that group. In the Group, the User
can also specify a Relation (someone they don’t want to be assigned to
be a Secret Santa for)
Here’s what I’ve got so far:
class User < ActiveRecord::Base
has_many :memberships
has_many :groups, :through => :memberships
end
class Group < ActiveRecord::Base
has_many :memberships
has_many :users, :through => :memberships
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :group
has_many :suggestions
has_and_belongs_to_many :relations,
:class_name => “Membership”,
:join_table => “relations_memberships”,
:association_foreign_key => “relation_id”,
:foreign_key => “membership_id”
end
class Suggestion < ActiveRecord::Base
belongs_to :membership
end
Am I approaching this correctly?