Skip to content

Instantly share code, notes, and snippets.

@eveevans
Created September 11, 2013 22:10
Show Gist options
  • Save eveevans/6530487 to your computer and use it in GitHub Desktop.
Save eveevans/6530487 to your computer and use it in GitHub Desktop.
Person in ....
# 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