http://edgeapi.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html under "Exception handling and rolling back" says that "*One should restart the entire transaction if an ActiveRecord::StatementInvalid occurred.*" My question is how? I tried wrapping the statements in two separate transaction block but that still doesn't work.
I have something like: self.transaction do bar = create!(params) rescue nil end unless bar self.transaction do bar = find_or_initialize_by(foo: foo) bar.update(params) end end and PG would still complain about it with "PG::Error: ERROR: current transaction is aborted, commands ignored until end of transaction block". So my question is whether there is a proper way of restarting the transaction? Thanks! Ken -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7e361619-ecf2-4b61-b8ee-d3b588b16e0c%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.