From b9600001794eb1d4601f5774b592a068b73fd7b5 Mon Sep 17 00:00:00 2001 From: Val Kotlarov Hoffman Date: Fri, 30 Aug 2013 13:29:20 +0300 Subject: [PATCH] FIX reload! within rails console --sandbox causes undefined method rollback upon exiting [https://github.com/rails/rails/issues/11834] --- activerecord/lib/active_record/railties/console_sandbox.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/railties/console_sandbox.rb b/activerecord/lib/active_record/railties/console_sandbox.rb index 604a220303..1a04950898 100644 --- a/activerecord/lib/active_record/railties/console_sandbox.rb +++ b/activerecord/lib/active_record/railties/console_sandbox.rb @@ -1,5 +1,7 @@ ActiveRecord::Base.connection.begin_transaction(joinable: false) at_exit do - ActiveRecord::Base.connection.rollback_transaction + if ActiveRecord::Base.connection.transaction_open? + ActiveRecord::Base.connection.rollback_transaction + end end