如何使用红宝石的旧宝石版本?

时间:2015-04-21 21:15:16

标签: ruby postgresql pg

Gem info - ruby​​ 1.8.7,pg 0.9.0,postgres 0.8.1 所有超级老宝石。我不能改变它。

代码 -

require 'rubygems'
require 'active_record'
require 'pg'
require 'postgres'

conn = PGconn.connect(:host => 'db.com', :port => 1234, :username => 'db1', :password => 'db1')
conn = PGconn.open
res = conn.exec("select * from a;")
PGconn.close

要求postgres行会导致以下消息,并且不允许执行代码。我如何使其工作?警告如下:

This is an old, deprecated version of the Ruby PostgreSQL driver that hasn't
been maintained or supported since early 2008.

You should install/require 'pg' instead.

If you need the 'postgres' gem for legacy code that can't be converted, you can
still install it using an explicit version, like so:

  gem install postgres -v '0.7.9.2008.01.28'
  gem uninstall postgres -v '>0.7.9.2008.01.28'

If you have any questions, the nice folks in the Google group can help:

  http://goo.gl/OjOPP / ruby-pg@googlegroups.com

0 个答案:

没有答案