search for: bunch_of_other_stuff

Displaying 1 result from an estimated 1 matches for "bunch_of_other_stuff".

2007 Jul 31
0
Force an object to previous state, when using lock_version
If I have an exception while trying to save an object, how can I tell Rails that it''s not saved yet? The object has a lock_version (used for optimistic locking). This is what I do: ins = MyClass.new( arguments ) begin transaction do ins.save! bunch_of_other_stuff() end rescue ins.save! # problem here! end The object''s save() sets the internal object state in a saved mode. It actually isn''t saved because the transaction failed. I can''t reload it, because it''s not in the database yet, and all subsequent saves are fail...