Kir*_*Kir 1 ruby-on-rails ruby-on-rails-3
我想从没有ActiveRecord适配器的Rails应用程序连接到SQL Server.
我跟着回答了这个问题.我安装了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
Run Code Online (Sandbox Code Playgroud)
但是当我尝试在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 '
Run Code Online (Sandbox Code Playgroud)
据我所知,deprecated宝石是必需的dbi.当我尝试安装最新版本的deprecated打印机时:
Bundler could not find compatible versions for gem "deprecated":
dbi depends on deprecated (= 2.0.1)
这是怎么回事?如何在没有Active Record的情况下从Rails 3连接到SQL Server?
小智 5
这是我在最终找到并阅读之后所做的:https://rails.lighthouseapp.com/projects/8994/tickets/5250-subclassesdescendants-is-not-a-symbol
gem uninstall deprecatedgem install rails-dbigem 'rails-dbi', :require => 'dbi'bundle update| 归档时间: |
|
| 查看次数: |
1298 次 |
| 最近记录: |