The [column_name]_changed? in the controller is not work, but in the model is ok?
original_name = "test1"
new_name = "test2"
@user = User.find(params[:id])
puts"__________#{@user.name}" # "test1"
@user.update_attributes(params[:user])
puts"__________#{@user.name}" # "test2"
@user.name_changed? # return false is't not work
From the fine manual:
Note the saves the record part. So after your
update_attributescall succeeds, all the new values have been written to the database and nothing will be left in the changed state; hence, all thex_changed?methods will return false.If you want something that is like
update_attributesbut doesn’t do thesave, then you ca useassign_attributesorattributes=instead:The
update_attributesmethod is just this:after all.