In the README file of the ActiveRecord docs
(http://api.rubyonrails.com/files/vendor/rails/activerecord/README.html)
it says:
Transaction support on both a database and object level. The latter is
implemented by using Transaction::Simple
# Just database transaction
Account.transaction do
david.withdrawal(100)
mary.deposit(100)
end
# Database and object transaction
Account.transaction(david, mary) do
david.withdrawal(100)
mary.deposit(100)
end
But the second case does not seem to actually be implemented. Test
case:
from script/console I run
irb> a = Account.create
=> #<Account id: 2, name: nil, balance: 0.0>
irb> Account.transaction do
irb* a.deposit(10.00)
irb> raise
irb> end
RuntimeError:
[[snip]]
irb> a.balance #Oops db didn''t change but object did
=> 10.0
irb> a.reload
=> #<Account id: 2, name: nil, balance: 0.0>
irb> Account.transaction(a) do #this should fix it
irb* a.deposit(10.00)
irb> raise
irb> end
ArgumentError: wrong number of arguments (1 for 0)
from (irb):23:in `transaction''
from (irb):23
What am I doing wrong here?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 05 Feb 2008, at 00:17, Starr Trader wrote:> In the README file of the ActiveRecord docs > (http://api.rubyonrails.com/files/vendor/rails/activerecord/ > README.html) > it says: > > Transaction support on both a database and object level. The latter is > implemented by using Transaction::Simple > > # Just database transaction > Account.transaction do > david.withdrawal(100) > mary.deposit(100) > end > > # Database and object transaction > Account.transaction(david, mary) do > david.withdrawal(100) > mary.deposit(100) > endObject level transactions have been deprecated in Rails 2, but you can use a plugin to restore its functionality: http://ryandaigle.com/articles/2007/3/20/what-s-new-in-edge-rails- object-transactions-are-out Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Peter De Berdt wrote:> On 05 Feb 2008, at 00:17, Starr Trader wrote: > > Object level transactions have been deprecated in Rails 2, but you > can use a plugin to restore its functionality: > http://ryandaigle.com/articles/2007/3/20/what-s-new-in-edge-rails- > object-transactions-are-out > > > Best regards > > Peter De BerdtShouldn''t this reference be removed from the documentation then? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 05 Feb 2008, at 22:13, Starr Trader wrote:>> Object level transactions have been deprecated in Rails 2, but you >> can use a plugin to restore its functionality: >> http://ryandaigle.com/articles/2007/3/20/what-s-new-in-edge-rails- >> object-transactions-are-out >> > Shouldn''t this reference be removed from the documentation then?I don''t know what site you are using, but I can''t find it in the official rails api docs at: http://api.rubyonrails.com/classes/ActiveRecord/Transactions/ ClassMethods.html It does come up at http://www.railsapi.org/ActiveRecord::Transactions::ClassMethods which means that unofficial rails api hasn''t been updated to the latest version. You should only rely on well generated api docs on your local computer and the official docs at api.rubyonrails.com (local docs install is still best, especially if you''re on edge) Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Peter De Berdt wrote:> On 05 Feb 2008, at 22:13, Starr Trader wrote: > >>> Object level transactions have been deprecated in Rails 2, but you >>> can use a plugin to restore its functionality: >>> http://ryandaigle.com/articles/2007/3/20/what-s-new-in-edge-rails- >>> object-transactions-are-out >>> >> Shouldn''t this reference be removed from the documentation then? >> You should only rely on well generated api docs on your local > computer and the official docs at api.rubyonrails.com (local docs > install is still best, especially if you''re on edge) > > > Best regards > > Peter De BerdtPlease take a look at the official docs here: (http://api.rubyonrails.com/files/vendor/rails/activerecord/README.html) What I quoted if from the 8th bullet point down. I do us my locally generated RDocs but I cannot link to them very well can I? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 06 Feb 2008, at 00:03, Starr Trader wrote:>>>> Object level transactions have been deprecated in Rails 2, but you >>>> can use a plugin to restore its functionality: >>>> http://ryandaigle.com/articles/2007/3/20/what-s-new-in-edge-rails- >>>> object-transactions-are-out >>>> >>> Shouldn''t this reference be removed from the documentation then? >> > >> You should only rely on well generated api docs on your local >> computer and the official docs at api.rubyonrails.com (local docs >> install is still best, especially if you''re on edge) > > Please take a look at the official docs here: > (http://api.rubyonrails.com/files/vendor/rails/activerecord/ > README.html) > > What I quoted if from the 8th bullet point down. > > I do us my locally generated RDocs but I cannot link to them very well > can I?:-) It must have slipped under the radar, I guess (it happens when it''s on a summary page). It would be nice if you could submit a patch for it so it doesn''t persist in later versions. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Peter De Berdt wrote:> On 06 Feb 2008, at 00:03, Starr Trader wrote: > >>> install is still best, especially if you''re on edge) >> >> Please take a look at the official docs here: >> (http://api.rubyonrails.com/files/vendor/rails/activerecord/ >> README.html) >> >> What I quoted if from the 8th bullet point down. >> >> I do us my locally generated RDocs but I cannot link to them very well >> can I? > > :-) > > It must have slipped under the radar, I guess (it happens when it''s > on a summary page). It would be nice if you could submit a patch for > it so it doesn''t persist in later versions. > > > Best regards > > Peter De BerdtPatch #11052 submitted. Thanks for all you help http://dev.rubyonrails.org/ticket/11052 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---