When I try to run this code, I get an exception when trying to
retrieve the connection:
:~/ruby$ ruby activerecordtest.rb
/usr/lib/ruby/1.8/readbytes.rb:23:in `readbytes': End of file reached
(EOFError)
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/message.rb:32:in `read'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/connection.rb:30:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/connection.rb:29:in `loop'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/connection.rb:29:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/postgres-compat.rb:23:in `new'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/postgres-compat.rb:23:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/postgresql_adapter.rb:24:in
`connect'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/postgresql_adapter.rb:24:in
`postgresql_connection'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
262:in `send'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
262:in `connection_without_query_cache='
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/query_cache.rb:54:in `connection='
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
230:in `retrieve_connection'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
78:in `connection'
from activerecordtest.rb:13
Yes, 1234 is not the actual port I'm using, I've obscured all
information in the establish_connection method except that it is a
postgresql DB that I'm trying to use. Anyway, the actual port that I
am using is correct, for I am able to use this database server through
an actual Rails project, and in my yml config, the port I have
specified there is the same that I tried to use in this script, which
did not work. Actually, here is the output if I use the incorrect
port, with the same script:
$ ruby activerecordtest.rb
/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/
connection.rb:138:in `initialize': Connection refused - connect(2)
(Errno::ECONNREFUSED)
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/connection.rb:138:in `new'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/connection.rb:138:in `establish_connection'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/connection.rb:25:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/postgres-compat.rb:23:in `new'
from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/
postgres-pr/postgres-compat.rb:23:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/postgresql_adapter.rb:24:in
`connect'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/postgresql_adapter.rb:24:in
`postgresql_connection'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
262:in `send'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
262:in `connection_without_query_cache='
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/query_cache.rb:54:in `connection='
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
230:in `retrieve_connection'
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
78:in `connection'
from activerecordtest.rb:13