metamaps--metamaps/app/policies/user_policy.rb
2016-10-04 22:28:10 +08:00

41 lines
494 B
Ruby

class UserPolicy < ApplicationPolicy
def index?
user.present?
end
def show?
user.present?
end
def create?
fail 'Create should be handled by Devise'
end
def update?
user == record
end
def destroy?
false
end
def details?
show?
end
def updatemetacodes?
update?
end
# API action
def current?
user == record
end
class Scope < Scope
def resolve
return scope.all if user.present?
scope.none
end
end
end