establish_connection only on need

I have one abstract ActiveRecord::Base class that establishes connection to other db, and it does every time it is included, on every environment load. It starts to establish it at script/console for example.

I need to move that establishing only when there is actual request per that model is made.

Are you doing something like this ?: class YourModel < ActiveRecord::Base   establish_connection :db_config end