Unable to connect to postgres on Fedora Core 5


#1

I have been struggling for hours trying to connect Rails to postgresql.
I have trawled google results - all to no avail! I have installed the
postgres gem but it doesn’t appear to install properly:

gem install postgres

Attempting local installation of ‘postgres’
Local gem file not found: postgres*.gem
Attempting remote installation of ‘postgres’
Building native extensions. This could take a while…
ruby extconf.rb install postgres
checking for cygwin32_socket() in -lwsock32… no
checking for socket() in -lsocket… no
checking for gethostbyname() in -linet… no
checking for gethostbyname() in -lnsl… yes
checking for sys/un.h… yes
checking for socket()… yes
checking for hsterror()… no
checking for gethostname()… yes
checking for PQsetdbLogin() in -lpq… yes
checking for PQsetClientEncoding()… yes
checking for pg_encoding_to_char()… yes
checking for PQescapeString()… yes
creating Makefile

make
i386-redhat-linux-gcc -fPIC -I. -I/usr/lib/ruby/1.8/i386-linux
-I/usr/lib/ruby/1.8/i386-linux -I. -DHAVE_SYS_UN_H -DHAVE_SOCKET
-DHAVE_GETHOSTNAME -DHAVE_PQSETCLIENTENCODING -DHAVE_PG_ENCODING_TO_CHAR
-DHAVE_PQESCAPESTRING -c postgres.c
i386-redhat-linux-gcc -shared -L"/usr/lib" -o postgres.so postgres.o
-lruby -lpq -lnsl -ldl -lcrypt -lm -lc

make install
make: Nothing to be done for `install’.
Successfully installed postgres-0.7.1

If I require ‘postgres’ in irb it fails to load, I have also set up this
in database.yml:

development:
adapter: postgres
database: railstest
username: martinto
password:
host: localhost

If I then type:

script/generate migration initial

I get a long stack trace which has this at the start:

/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:200:in
`establish_connection’: database configuration specifies nonexistent
postgres adapter (ActiveRecord::AdapterNotFound)

What am I doing wrong?


Martin Tomes
echo ‘martin at tomes x org x uk’
| sed -e ‘s/ x /./g’ -e ‘s/ at /@/’

Visit http://www.subversionary.org/


#2

On Thu, 2006-04-20 at 11:46 +0100, Martin Tomes wrote:

I have been struggling for hours trying to connect Rails to postgresql.
I have trawled google results - all to no avail! I have installed the
postgres gem but it doesn’t appear to install properly:
I have also set up this
in database.yml:
development:
adapter: postgres

I think you want this:

====================================
development:
adapter: postgresql

Yours,

Tom
http://tomcopeland.blogs.com/