# Establish\_connection issues

**URL:** <https://www.ruby-forum.com/t/establish-connection-issues/187646>\
**Category:** Rails\
**Created:** [April 27, 2010, 11:37am UTC](https://www.ruby-forum.com/t/establish-connection-issues/187646 "2010-04-27T11:37:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [April 27, 2010, 11:37am UTC](https://www.ruby-forum.com/t/establish-connection-issues/187646/1 "2010-04-27T11:37:17Z")

</div>

Hi,

I have created a new app but I would like to use some database tables  
from another application - so I am trying to use establish\_connection

Here is my code…

Model file

class User \< ActiveRecord::Base  
establish\_connection :external\_database\_development

Database.yml

…  
standard configurations that will run the rest of the app  
…  
external\_database\_development:  
adapter: postgresql  
database: name\_of\_db  
username: postgres  
password: mypass  
host: localhost  
port: 2810

When I try and load my app I get a 500 error.

Status: 500 Internal Server Error  
external\_database\_development database is not configured  
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/  
active\_record/connection\_adapters/abstract/connection\_specification.rb:  
62:in `establish_connection' C:/Users/incubator10/My Documents/Aptana Studio Workspace/ graduate_toolbox_dev/app/models/user.rb:3 C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:380:in`load\_without\_new\_constant\_marking’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/dependencies.rb:380:in `load_file' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:521:in`new\_constants\_in’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/dependencies.rb:379:in `load_file' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:259:in`require\_or\_load’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/dependencies.rb:425:in `load_missing_constant' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:80:in`const\_missing’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/dependencies.rb:92:in `const_missing' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/inflector.rb:361:in`constantize’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/inflector.rb:360:in `each' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/inflector.rb:360:in`constantize’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/core\_ext/string/inflections.rb:162:in `constantize' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/observer.rb:157:in`observed\_class’  
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/  
active\_record/observer.rb:183:in `observed_classes' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/observer.rb:166:in`initialize’  
C:/Ruby/lib/ruby/1.8/singleton.rb:94:in `new' C:/Ruby/lib/ruby/1.8/singleton.rb:94:in`instance’  
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/  
active\_record/observer.rb:38:in `instantiate_observers' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/observer.rb:36:in`each’  
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/  
active\_record/observer.rb:36:in `instantiate_observers' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/ action_controller/dispatcher.rb:16:in`define\_dispatcher\_callbacks’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/callbacks.rb:182:in `call' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/callbacks.rb:182:in`evaluate\_method’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/callbacks.rb:166:in `call' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/callbacks.rb:90:in`run’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/callbacks.rb:90:in `each' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/callbacks.rb:90:in`send’  
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/callbacks.rb:90:in `run' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/callbacks.rb:276:in`run\_callbacks’  
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/  
action\_controller/dispatcher.rb:52:in `send' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/ action_controller/dispatcher.rb:52:in`run\_prepare\_callbacks’  
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/  
action\_controller/dispatcher.rb:57:in `reload_application' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/ action_controller/reloader.rb:8:in`call’  
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/  
action\_controller/failsafe.rb:11:in `call' C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in`call’  
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in  
`synchronize' C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in`call’  
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/  
action\_controller/dispatcher.rb:106:in `call' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/rack/ static.rb:31:in`call’  
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in  
`call' C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in`each’  
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in  
`call' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/rack/ log_tailer.rb:17:in`call’  
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/  
content\_length.rb:13:in `call' C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/chunked.rb: 15:in`call’  
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/  
mongrel.rb:61:in `process' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/ mongrel.rb:159:in`process\_client’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/  
mongrel.rb:158:in `each' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/ mongrel.rb:158:in`process\_client’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/  
mongrel.rb:285:in `run' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/ mongrel.rb:285:in`initialize’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/  
mongrel.rb:285:in `new' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/ mongrel.rb:285:in`run’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/  
mongrel.rb:268:in `initialize' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/ mongrel.rb:268:in`new’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/  
mongrel.rb:268:in `run' C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/ mongrel.rb:34:in`run’  
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:  
111  
C:/Ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`require’  
./script/server:3  
-e:2:in `load’  
-e:2

Any help appreciated,

Thanks,

Dan
