1
我想使用cancan來允許更新模型的某個屬性,但不允許其他屬性。這是我的更新操作的樣子。Cancan允許更新模型的特定屬性
class UsersController < ApplicationController
load_and_authorize_resource
def update
respond_with User.update(params[:id], params[:user])
end
end
if resource.instance_of?教師
can [:read, :update], User do |user|
resource.users.include? user
end
我想老師能夠修改user.course_id但沒有別的。我該如何改變
can :update, User
要做我想做的事情。