Ruby on rails 如何停止设计用户在Rails 5中使用权威编辑其他用户

Ruby on rails 如何停止设计用户在Rails 5中使用权威编辑其他用户,ruby-on-rails,ruby,devise,authorization,pundit,Ruby On Rails,Ruby,Devise,Authorization,Pundit,我试图找出如何阻止用户编辑或删除其他用户的信息。我使用Desive设置用户,因此没有用户控制器。用户策略如下所示 class PostPolicy < ApplicationPolicy def index? true end def create? user.present? end def update? user.present? && user == post.user end def destroy?

我试图找出如何阻止用户编辑或删除其他用户的信息。我使用Desive设置用户,因此没有用户控制器。用户策略如下所示

class PostPolicy < ApplicationPolicy
  def index?
    true
  end

  def create?
    user.present?
  end

  def update?
    user.present? && user == post.user
  end

  def destroy?
    user.present? && user == post.user
  end

  private

  def post
    record
  end
end
类后策略
我设法停止允许其他用户删除或编辑不存在的帖子,但不知道在没有用户控制器的情况下如何做到这一点-我在Desive Gem中找不到代码,无法查看控制器在幕后做了什么,因此不知道如何在不破坏Desive其他功能的情况下更改其方法

非常感谢您的帮助