Thomas Adam
10/17/2007 5:38:00 PM
On 17/10/2007, Chad Perrin <perrin@apotheon.com> wrote:
> On Wed, Oct 17, 2007 at 11:21:15AM +0900, Ben Bleything wrote:
> > On Wed, Oct 17, 2007, Chad Perrin wrote:
> > > I have need to work with PostgreSQL via Ruby. What gems/modules do you
> > > recommend? Are there any quickstart-type howtos online to which you
> > > might direct me?
> >
> > If you're looking for an ORM, there is of course ActiveRecord, and
> > someone else already offered up Og.
>
> I'm not necessarily looking for ORM, though now that I think about it I
> can't help but wonder if every single programmatic interface between Ruby
> and a relational database might qualify in some manner as ORM (since
> "everything is an object" in Ruby). In the Perl world, I'd tend to use
But then, just because the language you're using means everything is
an object, does not mean to say that when you connect to a database
and start pulling stuff out of it that what you get is ORM. ORM is an
interface your application would define for itself, mapping to the
underlying tables/views/whatever in the database.
Ruby makes this easier in that you could just (at a crude level) map
an object you define to have properties, behaviour and scope of the
underlying tables, etc., in the database. Sometimes there is merit to
that -- and indeed, coming into this are things like patterns (the
factory pattern in particular is useful in ORM scenarios.)
> DBI for all things database-y, and was wondering what the preferred
> approach would be in the Ruby world especially in the case of PostgreSQL.
Having written numerous libraries (well, OK, two) in both perl and
ruby, I can honestly say that whilst it's somewhat "easier" in perl
(you're not forced to go down the abstracted route of ORM design) you
lose a lot of functionality -- the scope of what you can write in Perl
diminishes since the interface subroutines rarely map in an ORM way
[1]. Look into it heavily with Ruby -- it will make life easier.
-- Thomas Adam
[1] Anyone who things writing OO Perl is a good thing for this; think
again. OO perl is just broken.