pundit: sometimes no user

This commit is contained in:
Connor Turland 2016-03-13 02:27:05 +11:00
parent ada29c6832
commit f072e39c4c

View file

@ -1,7 +1,11 @@
class MapPolicy < ApplicationPolicy
class Scope < Scope
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