user.update_attribute(:pwd, pwd) 是这样理解吗: user.pwd = pwd 更新到对象 user.update 更行到数据库 这样两步吗? 而不是直接将 pwd 更新到数据库
def update(attributes)
# The following transaction covers any possible database side-effects of the
# attributes assignment. For example, setting the IDs of a child collection.
with_transaction_returning_status do
assign_attributes(attributes)
save
end
end
Yes, two steps. The last step is save
.
https://github.com/rails/rails/pull/6738#issuecomment-39584005
根据这个 PR,update_attribute
一度还被移除过。。。