3
我從表單中傳遞4個值。還原屬性的更改
attr1
attr2
attr3
attr4
在before_save
def before_save
if condition == true
# here i want to revert changes of attributes ...
# Right now i am doing this for reverting....
self.attr1 = self.attr1_was
self.attr2 = self.attr2_was
end
end
什麼更好的辦法來恢復除了一些屬性的變化?我想恢復除一個或兩個以外的所有屬性。
我不想返回錯誤。無聲地,我只想用最後的價值恢復它。 – 2010-09-22 19:31:49