I am running on Rails 3.2.22 and I can't get transaction/rollback working. This code should always print "WORLD" but actually, it will never work if raise is called. But according to Rails doc, it should always reach there. My question is - is there a way how to save @pb status into a database? If I decide to save the status before rollback, it will not save. If I save it after raise, it will not execute. Is there a way around that?
@pb = ProgressBar.create(..)
..
def import(user)
Thread.new do
ActiveRecord::Base.transaction do
errs = operation(user)
Rails.logger.info "HELLO"
if errs.any?
raise ActiveRecord::Rollback
end
end
Rails.logger.info "WORLD"
@pb.failed_import
end
end
Aucun commentaire:
Enregistrer un commentaire