users/1/edit
当我以其他用户身份登录时访问不会引发 AccessDenied 错误,我不知道为什么:
authorize_resource only: [:edit, :update]
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
redirect_to @user
else
render 'edit'
end
end
能力等级:
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
can :create, User
can :create, Group
can :update, User, id: user.id
end
end
如果我更改authorize_resource
为load_and_authorize_resource
然后它按预期工作。但这不应该是相关的,当然?