fesplugas/typus — pull request #388 by sodercober (2012-09-13 21:29:15+00:00)
Title: Use standard API to fetch Connection Adapter. Fixes bug on Heroku.

If Typus is deployed in environment where there is no `config/database.yml` and DB connection is configured using `DATABASE_URL` variable, then `Rails.configuration.database_configuration` returns nil. I'm having this issue on Heroku.

In result, "Search" feature does not work:

Started GET "/admin/users?search=john" for 11.22.33.44 at 2012-09-13 19:53:37 +0000
Processing by Admin::UsersController#index as HTML
Parameters: {"search"=>"john"}
Completed 500 Internal Server Error in 180ms

NoMethodError (undefined method `[]' for nil:NilClass):
vendor/bundle/ruby/1.9.1/gems/typus-3.1.10/lib/typus/orm/active_record/search.rb:23:in `block (2 levels) in build_search_conditions'
vendor/bundle/ruby/1.9.1/gems/typus-3.1.10/lib/typus/orm/base/search.rb:72:in `block (2 levels) in build_conditions'
vendor/bundle/ruby/1.9.1/gems/typus-3.1.10/lib/typus/orm/base/class_methods.rb:149:in `adapter'
vendor/bundle/ruby/1.9.1/gems/typus-3.1.10/lib/typus/orm/active_record/search.rb:15:in `block in build_search_conditions'
vendor/bundle/ruby/1.9.1/gems/typus-3.1.10/lib/typus/orm/active_record/search.rb:15:in `each'
vendor/bundle/ruby/1.9.1/gems/typus-3.1.10/lib/typus/orm/base/search.rb:70:in `each'
vendor/bundle/ruby/1.9.1/gems/typus-3.1.10/lib/typus/orm/active_record/search.rb:9:in `build_search_conditions'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/bundle/ruby/1.9.1/gems/typus-3.1.10/app/controllers/admin/resources_controller.rb:17:in `index'

This commit fixes this by using standard API to fetch current connection adapter, regardless which method it was configured with (`database.yml` or `DATABASE_URL`).

See http://apidock.com/rails/ActiveRecord/Base/connection_config/class