我尝试使用ActiveRecord sqlserver adapter连接到远程SQL Server视图:
@connection = ActiveRecord::Base.establish_connection(
:adapter => "sqlserver",
:dsn => "rms",
:hosts => "xxx.xxx.xx.xx",
:database => "V_MLS_ECOMM_STORE_SOH",
:ports => "1521",
:username => "xxxxxx",
:passwords => "xxxxxxx")
@connection.connected?
始终返回false。
答案 0 :(得分:0)
做这样的事情:
class LegacyTable < ActiveRecord::Base
establish_connection({
:adapter => "sqlserver",
:host => "host",
:username => "user",
:password => "pass",
:database => "dbname"
})
参考:https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/250