我已经安装了ruby db i-0.4.3,并试图连接到一个sql server数据库。gem安装没有问题。deprecate方法正在gem的date.rb文件中使用。提前谢谢你的帮助。
克里斯
这是我的代码:

require 'dbi'
$LOAD_PATH.unshift(File.dirname(__File__))

oConn = DBI.connect('DBI:ADO:Provider=SQLNCLI;Data Source="UPSTAIRS\SQLEXPRESS";
                      Integrated Security=SSPI;Initial Catalog=SQLClass')

oConn.disconnect if dbh

下面是我得到的错误:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/dbi-0.4.3/lib/dbi/utils/date.rb:57:in `<class:Date>': undefined method `deprecate' for DBI::Date:Class (NoMethodError)
  from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dbi-0.4.3/lib/dbi/utils/date.rb:7:in `<module:DBI>'
  from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dbi-0.4.3/lib/dbi/utils/date.rb:1:in `<top (required)>'
  from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dbi-0.4.3/lib/dbi/utils.rb:56:in `<top (required)>'
  from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dbi-0.4.3/lib/dbi.rb:50:in `<top (required)>'
  from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
  from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
  from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
  from C:/SQLClassScripts/RubyScripts/LoadData/lib/LoadDataMain.rb:4:in `<main>'

最佳答案

我不知道dbi,但deprecate-方法似乎来自deprecated-gem
做一个

gem 'deprecated'
require 'deprecated'

在代码帮助的开头?

关于ruby - 在Ruby DBI Gem中获取未定义的方法'deprecate'错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9456768/

10-13 02:14