Module: ActiveRecord::Tenanted::Console::ReloadHelper

Defined in:
lib/active_record/tenanted/console.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/active_record/tenanted/console.rb', line 18

def execute
  tenant = if Rails.env.local? && (connection_class = ActiveRecord::Tenanted.connection_class)
    connection_class.current_tenant
  end

  super
ensure
  # We need to reload the connection class to ensure that we get the new (reloaded) class.
  if tenant && (connection_class = ActiveRecord::Tenanted.connection_class)
    connection_class.current_tenant = tenant
  end
end