Permalink
Browse files

Wrap save! in a transaction. Closes #6324.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5281 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 5e08c66 commit 629b8af2b0e143b18aa4206beb6006b9f9898788 @jeremy jeremy committed Oct 10, 2006
Showing with 7 additions and 3 deletions.
  1. +1 −1 activerecord/CHANGELOG
  2. +6 −2 activerecord/lib/active_record/transactions.rb
View
@@ -1,6 +1,6 @@
*SVN*
-* Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [lukfugl, Jeremy Kemper]
+* Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [Jacob Fugal, Jeremy Kemper]
* Add #delete support to has_many :through associations. Closes #6049 [Martin Landers]
@@ -11,7 +11,7 @@ def self.included(base)
base.extend(ClassMethods)
base.class_eval do
- [:destroy, :save].each do |method|
+ [:destroy, :save, :save!].each do |method|
alias_method_chain method, :transactions
end
end
@@ -115,9 +115,13 @@ def transaction(*objects, &block)
def destroy_with_transactions #:nodoc:
transaction { destroy_without_transactions }
end
-
+
def save_with_transactions(perform_validation = true) #:nodoc:
transaction { save_without_transactions(perform_validation) }
end
+
+ def save_with_transactions! #:nodoc:
+ transaction { save_without_transactions! }
+ end
end
end

0 comments on commit 629b8af

Please sign in to comment.