Postgres adapter issues with Rails 2.1: ruby-pg is the answer!

While upgrading Rails 2.0.2 sites to Rails 2.1.1, I encountered a
weird postgres adapter problem. Although the old postgresql adapter
(aka ruby-postgres) works fine with Rails 2.1.1 on my Mac dev box
(running PG 8.2.6) and also works fine with Rails 2.0.2 apps on a
Debian etch staging server (running PG 8.2.1), this error occurs when
trying to cap deploy 2.1.1 apps on the Debian box: "PQserverVersion
not supported by this client version". This error occurs at the point
of the rake migration task.

This error has everything to do with the change from Rails 2.0.2 to
2.1.1; by changing the version of Rails back to 2.0.2 in config/
environment.rb, the rake migration proceeds fine and the PG db
connects fine in script/console. This problem is most mysterious, as
it didn't manifest itself on my Mac (the only difference that I can
easily see is the slightly newer PG version).

However, the solution turns out to be easy: simply use the ruby-pg
adapger (https://rubyforge.org/projects/ruby-pg/). The omnipresent
Fred C had suggested that this adapter might not work on pre-2.1 apps
(http://www.ruby-forum.com/topic/156143), but it appears to work just
fine here.

Furthermore, the ruby-pg adapter project is in the reliable hands of
Jeff Davis, a superstar whose abilities mean that PG has a brilliant
future with Rails. Hurrah for that!

Anyway, I hope that this saves someone else some time.

In Rails edge, ruby-pg is mandatory. ruby-postgres doesn't work.

A report is send in lighthouse :
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/996-nomethoderror-undefined-method-transaction_status-for-pgconn0xb719eb0c#ticket-996-3

On my Debian Etch box I have installed PostgreSQL from backports repo.

When I want to install ruby-pg with "gem1.8 install ruby-pg", I get the
following error:

--
Building native extensions. This could take a while...
ERROR: Error installing ruby-pg:
       ERROR: Failed to build gem native extension.

I had the same problem.

I have some additional questions.

Why is the "official" postgres gem for rails ruby-pr when it doesn't
work on windows at all and doesn't install on linux out of the box?

What happened to postgres-pr?

Why are there so many gems for postgres and why are so many of them abandoned?

Is postgres a second class citizen in rails?