pundit: fix queries

This commit is contained in:
Connor Turland 2016-03-12 10:10:31 +11:00
parent 5f3f5212c5
commit bd3afff069
3 changed files with 4 additions and 3 deletions

View file

@ -5,7 +5,8 @@ class MappingPolicy < ApplicationPolicy
# it would be nice if we could also base this on the mappable, but that
# gets really complicated. Devin thinks it's OK to SHOW a mapping for
# a private topic, since you can't see the private topic anyways
scope.joins(:maps).where('maps.permission IN ("public", "commons") OR maps.user_id = ?', user.id)
scope.joins(:maps).where('maps.permission IN (?) OR maps.user_id = ?',
["public", "commons"], user.id)
end
end

View file

@ -1,7 +1,7 @@
class SynapsePolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.where('permission IN ("public", "commons") OR user_id = ?', user.id)
scope.where('permission IN (?) OR user_id = ?', ["public", "commons"], user.id)
end
end

View file

@ -1,7 +1,7 @@
class TopicPolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.where('permission IN ("public", "commons") OR user_id = ?', user.id)
scope.where('permission IN (?) OR user_id = ?', ["public", "commons"], user.id)
end
end