title: Too many database connections created in rails 2.3.18 application
body: <p>We have many models like the below one. </p>
  
  <pre><code>class User &lt; ActiveRecord::Base
   create_connection
  
    def create_connection  
      # we have used this ActiveRecord::Base.configurations[current_environment] for connection_info 
      self.establish_connection connection_info
    end
  end 
  </code></pre>
  
  <p>After using many models of similar types, many database connections are being created for the remote database. So we are getting the below error message for remote Postgres database. </p>
  
  <pre><code>2013-12-04T12:18:28.360740+00:00 app[web.1]:   FATAL:  too many connections for role "ycjcwpowlrmvhi"
  </code></pre>
  
  <p>Actually we have two applications on heroku and each application accesses the other's database.</p>
  
  <p>How we can close these many database connection after executing the query?</p>
  
  <p>We are also getting the below error some times.</p>
  
  <pre><code>2013-12-06T09:36:27.952787+00:00 app[web.1]: Processing StaffController#index (for 202.45.6.95 at 2013-12-06 09:36:27) [GET]
  2013-12-06T09:36:16.453533+00:00 heroku[router]: at=info method=GET path=/javascripts/application.js?1386322453 host=demomanager.herokuapp.com fwd="202.45.6.95" dyno=web.1 connect=1ms service=3ms status=200 bytes=5025
  2013-12-06T09:36:32.935950+00:00 app[web.1]: 
  2013-12-06T09:36:32.935950+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UnableToSend: SSL error: decryption failed or bad record mac
  2013-12-06T09:36:32.935950+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
  2013-12-06T09:36:32.935950+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
  2013-12-06T09:36:32.935950+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  2013-12-06T09:36:32.935950+00:00 app[web.1]:              WHERE a.attrelid = '"tags"'::regclass
  2013-12-06T09:36:32.935950+00:00 app[web.1]:                AND a.attnum &gt; 0 AND NOT a.attisdropped
  2013-12-06T09:36:32.935950+00:00 app[web.1]:              ORDER BY a.attnum
  2013-12-06T09:36:32.935950+00:00 app[web.1]: ):
  </code></pre>