2

Connecting to postgres with rails was no big deal. rails -d postgresql app_name, setup the database.yml and voila. I cannot, however, use postgres with just a little test script

I've tried installing the gems postgres, dbi & dbd-pg, pg, and ruby-pg, but with pg/ruby-pg and postgres it fails at the require for require 'postgres' or require 'pg'. With require 'dbi' I get past the require, but it can't load the driver....so how is rails doing it with the same set of packages? In fact I removed all the afore mentioned and found I only needed the 'pg' gem for everything to work fine with rails. Any advice?

Felix
  • 699
  • 2
  • 9
  • 24

1 Answers1

3

Are you remembering to add a require 'rubygems' to your source, or invoke ruby with a -rubygems argument, or add RUBYOPT=rubygems to your environment? You need to do one of those to actually load the gem machinery that allows require to find your gems.

Brian Campbell
  • 322,767
  • 57
  • 360
  • 340
  • Thank you very much. Coming from the land of Perl, I had no idea. You saved me a lot of wasted time. – Felix Jan 04 '10 at 04:55