Module: PG::ApplicationName::ClassMethods

Defined in:
lib/pg-app-name.rb

Instance Method Summary collapse

Instance Method Details

#establish_connection_with_application_name(*args) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/pg-app-name.rb', line 17

def establish_connection_with_application_name(*args)
  result = establish_connection_without_application_name(*args)
  appname = ENV['PG_APP_NAME'] || "ruby"
  appname = "#{appname}_without_pool"
  ::ActiveRecord::Base.connection.execute("set application_name = '#{appname}';")
  result
end