Created
September 11, 2013 22:10
-
-
Save eveevans/6530487 to your computer and use it in GitHub Desktop.
Person in ....
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
# current_account.posts.visible_to(current_user) | |
module Visible | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def visible_to(person) | |
where \ | |
"(#{table_name}.bucket_id IN (?) AND | |
#{table_name}.bucket_type = 'Project') OR | |
(#{table_name}.bucket_id IN (?) AND | |
#{table_name}.bucket_type = 'Calendar')", | |
person.projects.pluck('projects.id'), | |
calendar_scope.pluck('calendars.id') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment