Skip to content

Commit 1bba5fb

Browse files
committed
Fix appname resolution when outside Rails context
The adapter can be used outside a Rails context so TinyTDS appname config should be able to be resolved if a Rails application was not detected. Fix #942.
1 parent 89f90b6 commit 1bba5fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def config_appname(config)
119119
end
120120

121121
def rails_application_name
122-
return nil if Rails.application.nil?
123-
124122
Rails.application.class.name.split("::").first
123+
rescue
124+
nil # Might be in a Rails context so we fallback to `nil`.
125125
end
126126

127127
def config_login_timeout(config)

0 commit comments

Comments
 (0)