Created
May 10, 2013 23:43
-
-
Save rintaun/5558271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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