Wednesday, June 25, 2008

Rails + PostgreSQL

I'm doing a Rails internship this summer with LocaModa, started today. (I've previously worked for/on Jango, which was my first RoR experience.)

Getting postgres installed on Ubuntu Hardy was just a matter of apt-get'ing, getting the postgres gem installed required me to grab libpq-dev (evidently a replacement for postgresql-dev, and I have no idea why that's a Q instead of a G) first.

In order to get Rails capable of talking to postgres, I had to modify pg_hba.conf: the actual (ie, non-commented) content of mine is two lines that look like this:

local all all md5

followed by this:
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5

the effect of the first line that begins with 'local' is to allow username/password logins from users other than the default postgres user.

Without that, attempting to login from another user account (for instance, the primary one on my laptop) resulted in this error:

rails FATAL: Ident authentication failed for user "postgres"

While I could have just started using the postgres user account for work, that's just assy.

Not sure how much of a hassle this was compared to the setup on OS X (as far as I can tell, rails dev happens almost entirely on either OS X or Ubuntu), but it was pretty reasonable and with slight documentation improvements would have been trivial.

Resulting convictions:

*PostgreSQL is less newbie-friendly than MySQL, but is a substantially better tool. (going back to my CRREL days, has support for GIS. more recently, was just more pleasant to work with. the backslash commands are useful as all get-out)

*Rails continues to be the best tool in its class, probably in the field period.

*Hardy is probably the best moderately mainstream OS out there, although it is occasionally a hassle.

No comments: