Skip to content

Instantly share code, notes, and snippets.

@rintaun
Created May 10, 2013 23:43
Show Gist options
  • Save rintaun/5558271 to your computer and use it in GitHub Desktop.
Save rintaun/5558271 to your computer and use it in GitHub Desktop.
class User < Sequel::Model
one_to_many :memberships
many_to_many :teams, :join_table => :memberships
end
class Membership < Sequel::Model
one_to_many :users
one_to_many :teams
end
class Team < Sequel::Model
one_to_many :memberships
many_to_many :users, :join_table => :memberships
def membership_id
# ???
end
def hash_with_membership_id
hash = values
hash[:membership_id] = membership_id
hash
end
end
User[1].teams.collect { |t| t.hash_with_membership_id }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment