aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHongli Lai (Phusion) <hongli@phusion.nl>2009-03-23 15:00:17 +0100
committerHongli Lai (Phusion) <hongli@phusion.nl>2009-03-23 15:00:17 +0100
commit1bd3d255eb43562a44fd1f907d82ec80db2872d3 (patch)
treeaac96ecae0bb1e521a0310f6bac1410112ddb964 /lib
parenta42dba642e86f3f27d8b2e67b632d2e377b6074c (diff)
Make sure that without_locking reverts AR::Base.lock_optimistically to its old value even if the given block raises an exception.rails_2
Diffstat (limited to 'lib')
-rw-r--r--lib/acts_as_versioned.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/acts_as_versioned.rb b/lib/acts_as_versioned.rb
index 5a0e6dc62..e7a8ce780 100644
--- a/lib/acts_as_versioned.rb
+++ b/lib/acts_as_versioned.rb
@@ -471,9 +471,11 @@ module ActiveRecord #:nodoc:
def without_locking(&block)
current = ActiveRecord::Base.lock_optimistically
ActiveRecord::Base.lock_optimistically = false if current
- result = block.call
- ActiveRecord::Base.lock_optimistically = true if current
- result
+ begin
+ block.call
+ ensure
+ ActiveRecord::Base.lock_optimistically = true if current
+ end
end
end
end