Mirror318
Mirror318

Reputation: 12693

Rails: What's the difference between ActiveRecord::Base.transaction and MyClass.transaction?

I'm looking at the docs here http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html

One example it gives is:

ActiveRecord::Base.transaction do
  david.withdrawal(100)
  mary.deposit(100)
end

Another example in the docs is:

Account.transaction do
  balance.save!
  account.save!
end

What's the difference between the Base's method and the Account's method?

Upvotes: 7

Views: 5570

Answers (1)

quazar
quazar

Reputation: 590

The account model inherits from ActiveRecord::Base so both are actually the same methods.

Upvotes: 8

Related Questions