pundit: sometimes no user
This commit is contained in:
parent
ada29c6832
commit
f072e39c4c
1 changed files with 5 additions and 1 deletions
|
@ -1,7 +1,11 @@
|
||||||
class MapPolicy < ApplicationPolicy
|
class MapPolicy < ApplicationPolicy
|
||||||
class Scope < Scope
|
class Scope < Scope
|
||||||
def resolve
|
def resolve
|
||||||
scope.where('maps.permission IN (?) OR maps.user_id = ?', ["public", "commons"], user.id)
|
if user
|
||||||
|
scope.where('maps.permission IN (?) OR maps.user_id = ?', ["public", "commons"], user.id)
|
||||||
|
else
|
||||||
|
scope.where('maps.permission IN (?)', ["public", "commons"])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue