Last active
August 29, 2015 14:02
-
-
Save mikecmpbll/a891560d099e0338df9f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Party < AR::Base | |
belongs_to :user | |
belongs_to :session | |
end |
This file contains hidden or 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 Session < AR::Base | |
has_many :parties | |
has_many :users, through: :parties | |
end |
This file contains hidden or 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 < AR::Base | |
has_many :parties | |
has_many :sessions, through: :parties | |
has_many :fellow_party_animals2, -> { where.not(id: self.id).uniq }, through: :sessions, class_name: "User" | |
def fellow_party_animals | |
User.joins(:sessions).where(sessions: { id: sessions }).where.not(id: id).uniq | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment