How to abandon/rollback the modifications done into a model entity?
I changed some value of an entity from the db, but now I want to discard all the changes. How can I do this?
I tried following:
u = User.find(1)
u.nick =开发者_Python百科 "dddd"
u.abandon? #i didn't want rollback the chage of the u
try
u.reload
It'll reload the entity from the database.
if you don't save it (by using u.save), then it is not made into the persistent storage. You can just do u = User.find(1) again to reload the value from the db.
加载中,请稍侯......
精彩评论