lib/rage/rails.rb in rage-rb-0.7.0 vs lib/rage/rails.rb in rage-rb-1.0.0

- old
+ new

@@ -28,9 +28,24 @@ end end end end +# release ActiveRecord connections on yield +if defined?(ActiveRecord) + class Fiber + def self.defer + res = Fiber.yield + + if ActiveRecord::Base.connection_pool.active_connection? + ActiveRecord::Base.connection_handler.clear_active_connections! + end + + res + end + end +end + # plug into Rails' Zeitwerk instance to reload the code Rails.autoloaders.main.on_setup do if Iodine.running? Rage.code_loader.rails_mode_reload end