Created
August 12, 2013 20:42
-
-
Save trappist/6214983 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
| scope :conjoins, -> { joins("LEFT JOIN connections ON connections.initiator_id=users.id OR connections.recipient_id=users.id") } | |
| scope :friends_with, ->(other) { conjoins.where("(connections.initiator_id=:uid OR connections.recipient_id=:uid) AND users.id != :uid", :uid => other.id) } | |
| scope :blockjoins, -> { joins("LEFT JOIN blockings ON blockings.blocker_id=users.id OR blockings.blocked_id=users.id") } | |
| scope :blocked_from, ->(other) { blockjoins.where("(blockings.blocker_id=:uid OR blockings.blocked_id=:uid) AND users.id != :uid", :uid => other.id) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment