activerecord_url_connections 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,8 @@ module ActiveRecordURLConnections
|
|
13
13
|
spec.reject!{ |key,value| value.nil? }
|
14
14
|
spec.merge!(split_query_options(config.query))
|
15
15
|
spec
|
16
|
+
rescue URI::InvalidURIError
|
17
|
+
return nil
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
@@ -27,11 +29,7 @@ ActiveRecord::Base.class_eval do
|
|
27
29
|
alias_method :establish_connection_without_url, :establish_connection
|
28
30
|
def establish_connection(spec = nil)
|
29
31
|
spec ||= ENV["DATABASE_URL"]
|
30
|
-
if spec.is_a?(String)
|
31
|
-
spec = ActiveRecordURLConnections.parse(spec)
|
32
|
-
end
|
33
|
-
establish_connection_without_url(spec)
|
34
|
-
rescue URI::InvalidURIError
|
32
|
+
spec = ActiveRecordURLConnections.parse(spec) if spec.is_a?(String)
|
35
33
|
establish_connection_without_url(spec)
|
36
34
|
end
|
37
35
|
end
|