pundit: fix queries
This commit is contained in:
parent
0095a8daf4
commit
c7075dab48
3 changed files with 4 additions and 3 deletions
|
@ -5,7 +5,8 @@ class MappingPolicy < ApplicationPolicy
|
||||||
# it would be nice if we could also base this on the mappable, but that
|
# 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
|
# 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
|
# 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class SynapsePolicy < ApplicationPolicy
|
class SynapsePolicy < ApplicationPolicy
|
||||||
class Scope < Scope
|
class Scope < Scope
|
||||||
def resolve
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class TopicPolicy < ApplicationPolicy
|
class TopicPolicy < ApplicationPolicy
|
||||||
class Scope < Scope
|
class Scope < Scope
|
||||||
def resolve
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue