Hello! According to ActiveRecord transactions documentation, User.transaction do User.create(:username => ''Kotori'') User.transaction(:requires_new => true) do User.create(:username => ''Nemu'') raise ActiveRecord::Rollback end end User.find(:all) # => Returns only Kotori But I get both records in database (tested on PostgreSQL and MySQL). In this case: User.transaction do User.create(:username => ''Kotori'') User.transaction(:requires_new => true) do User.create(:username => ''Nemu'') raise ''something'' # ActiveRecord::Rollback end end everything seems to be okay. Also, in cases/transactions_test.rb there is no test for raising AR::Rollback, only for generic raise. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Sorry, this was my fail According to link bellow this is a bug in documentation https://rails.lighthouseapp.com/projects/8994/tickets/1951-activerecordrollback-does-not-work-in-nested-transactions On 8 дек, 16:47, Ivan Evtuhovich <evtuhov...@gmail.com> wrote:> Hello! > > According to ActiveRecord transactions documentation, > > User.transaction do > User.create(:username => ''Kotori'') > User.transaction(:requires_new => true) do > User.create(:username => ''Nemu'') > raise ActiveRecord::Rollback > end > end > > User.find(:all) # => Returns only Kotori > > But I get both records in database (tested on PostgreSQL and MySQL). > In this case: > > User.transaction do > User.create(:username => ''Kotori'') > User.transaction(:requires_new => true) do > User.create(:username => ''Nemu'') > raise ''something'' # ActiveRecord::Rollback > end > end > > everything seems to be okay. > > Also, in cases/transactions_test.rb there is no test for raising > AR::Rollback, only for generic raise.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Here a patch to documentation https://gist.github.com/733479 On 8 дек, 18:56, Ivan Evtuhovich <evtuhov...@gmail.com> wrote:> Sorry, this was my fail > > According to link bellow this is a bug in documentation > > https://rails.lighthouseapp.com/projects/8994/tickets/1951-activereco... > > On 8 дек, 16:47, Ivan Evtuhovich <evtuhov...@gmail.com> wrote: > > > Hello! > > > According to ActiveRecord transactions documentation, > > > User.transaction do > > User.create(:username => ''Kotori'') > > User.transaction(:requires_new => true) do > > User.create(:username => ''Nemu'') > > raise ActiveRecord::Rollback > > end > > end > > > User.find(:all) # => Returns only Kotori > > > But I get both records in database (tested on PostgreSQL and MySQL). > > In this case: > > > User.transaction do > > User.create(:username => ''Kotori'') > > User.transaction(:requires_new => true) do > > User.create(:username => ''Nemu'') > > raise ''something'' # ActiveRecord::Rollback > > end > > end > > > everything seems to be okay. > > > Also, in cases/transactions_test.rb there is no test for raising > > AR::Rollback, only for generic raise.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.