Created
November 30, 2012 19:40
-
-
Save srbiv/4178035 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
@messages = Message.search do | |
any_of do | |
with(:user_ids, current_user.id) | |
all_of do | |
with(:user_ids).blank? | |
with(:school_ids, current_user.affiliated_school_ids.map {|s| s.to_s }) | |
end | |
all_of do | |
with(:user_ids).blank? | |
with(:school_ids).blank? | |
with(:customer_ids, current_user.affiliated_customer_ids.map { |c| c.to_s }) | |
end | |
unless current_user.affiliated_customer.contests.empty? | |
all_of do | |
with(:user_ids).blank? | |
with(:school_ids).blank? | |
with(:customer_ids).blank? | |
with(:contest_ids, current_user.affiliated_customer.contests.map { |c| c.id.to_s }) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment