rails/rails — pull request #16542 by seamusabshere (2014-08-18 13:19:45+00:00)
Title: Make sure :checkout_timeout and :dead_connection_timeout are numbers

If `:checkout_timeout` (or `:dead_connection_timeout`) is specified with `ENV['DATABASE_URL']`, then you may get

```
NoMethodError: undefined method `-' for "5":String
from /Users/myuser/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:182:in `block in wait_poll'
```

For example:

```
$ rails c
Loading development environment (Rails 4.1.4)
[1] pry(main)> ENV['DATABASE_URL']
=> "postgres://myuser:@127.0.0.1/mydb?pool=3&checkout_timeout=5"
[2] pry(main)> ActiveRecord::Base.connection_config
=> {:adapter=>"postgresql", :database=>"mydb", :encoding=>"utf8", :min_messages=>"warning", :pool=>"3", :timeout=>5000, :checkout_timeout=>"5", :username=>"myuser", :host=>"127.0.0.1"}
[3] pry(main)> threads = 10.times.map { Thread.new { c = ActiveRecord::Base.connection_pool.checkout; sleep 10 } }
=> [#,
#,
#,
#,
#,
#,
#,
#,
#,
#]
[4] pry(main)> threads.each(&:join)
NoMethodError: undefined method `-' for "5":String
from /Users/myuser/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:182:in `block in wait_poll'
```

In this change, I use #to_f instead of #to_i because these timeouts are specified in seconds instead of milliseconds