开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜