#note the field attribute is not a field
#the field attribute I'm trying to set above to what are given in the params hash
def update_user
field = params[:field]
@user = User.find(params[:id])
@user.field = !@user.field
@user.save(false)
render :nothing => true
end
为什么不发送has with params并更新
update_attributes(params[:user])
? 因为用户属性是受保护的,这样更新布尔值就更容易了。