【发布时间】:2011-04-24 07:48:24
【问题描述】:
我想在没有 ActiveRecord 适配器的情况下从 Rails 应用程序连接到 SQL Server。
我关注了this question 的答案。我安装了ruby-odbc gem 并从 ruby 脚本连接到 SQL Server 没有任何问题。
db = DBI.connect('dbi:ODBC:ACUMENSERVER', 'login', 'password')
select = db.prepare('SELECT * from customer WHERE id = 1')
select.execute
while rec = select.fetch do
puts rec.to_s
end
db.disconnect
但是当我尝试在 Rails 控制器中执行此代码时,会发生错误:
{:forgery_whitelisted?=>"it is just an alias for 'get?' now, update your code"} is not a symbol
/home/user/.rvm/gems/ruby-1.9.2-p136/gems/deprecated-2.0.1/lib/deprecated.rb 176 in `instance_method'
/home/user/.rvm/gems/ruby-1.9.2-p136/gems/deprecated-2.0.1/lib/deprecated.rb 176 in `block in '
据我所知,dbi 需要 deprecated gem。当我尝试安装最新版本的deprecated bundler 时打印:
Bundler could not find compatible versions for gem "deprecated":
dbi depends on deprecated (= 2.0.1)
怎么了?如何在没有 Active Record 的情况下从 Rails 3 连接到 SQL Server?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3