activerecord_url_connections 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -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
|