Skip to content

Instantly share code, notes, and snippets.

View voltechs's full-sized avatar

Dale voltechs

  • Notion, Twilight Coders
  • Denver
View GitHub Profile
class Membership < ActiveRecord::Base
# attr_accessible :title, :body
set_primary_keys :user_id, :group_id
belongs_to :user
belongs_to :group
# Weird that we have to say "belongs_to", but it works.
belongs_to :role
scope :roles_in_group, lambda { |g| { :conditions => { :roles => {:memberships => {:group => g.ancestors}}}}}