开发者

Manually connect to PostgreSQL with Ruby

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜