According to the ActiveRecord documentation, any exception thrown inside a transaction block must rollback all updates have been made within the transaction.
http://api.rubyonrails.org/classes/ActiveRecord/Rollback.html => "Normally, raising an exception will cause the transaction method to rollback the database transaction and pass on the exception" On Jul 23, 1:06 pm, Me <chabg...@gmail.com> wrote: > save! just throws an error if there is an issue. Do you have > validations that are supposed to cause an exception in that case? > > On Jul 23, 10:45 am, Carlos Forero <ecarlosfor...@gmail.com> wrote: > > > > > With : > > PostgreSQL 8.4 or postgresql-8.3 > > rails 2.3.4 > > pg 9.x or pg 8.x > > > I test this code: > > ========================= > > class NkiBatch < ActiveRecord::Base > > Bank.connection.transaction do > > > bank = Bank.new(:name => "ddsjdsjdsjk") > > bank.save! > > raise ActiveRecord::Rollback.new > > end > > end > > > and this: > > ========================= > > class NkiBatch < ActiveRecord::Base > > Bank.connection.transaction do > > > bank = Bank.new(:name => "ddsjdsjdsjk") > > bank.save! > > raise Exception.new > > end > > end > > > and this: > > ========================= > > class NkiBatch < ActiveRecord::Base > > Bank.connection.transaction do > > > bank = Bank.new(:name => "ddsjdsjdsjk") > > bank.save! > > raise "Please, rollback" > > end > > end > > > but the record bank is saved succesfully into database > > > (I reported the problem in the community of pg driver, but they > > demonstrated that the problem is not the pg > > driverhttp://bitbucket.org/ged/ruby-pg/issue/37/fail-rollback-transaction-w...) -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.