Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 连接到多个Rails DBs、SQLite3和SQLServer2008_Ruby On Rails 3_Sql Server 2008_Activerecord_Sqlite - Fatal编程技术网

Ruby on rails 3 连接到多个Rails DBs、SQLite3和SQLServer2008

Ruby on rails 3 连接到多个Rails DBs、SQLite3和SQLServer2008,ruby-on-rails-3,sql-server-2008,activerecord,sqlite,Ruby On Rails 3,Sql Server 2008,Activerecord,Sqlite,我正在尝试使用以下gem连接到名为Demand的SQL server: “嗯 我正在遵循《Rails食谱》一书中的食谱#3 这是我的database.yml文件: demand: adapter: sqlserver host: 172.21.148.01 port: 1433 database: Demand username: DEapp password: @pp1user timeout: 5000 从rails控制台,当我使用Demand.connecti

我正在尝试使用以下gem连接到名为Demand的SQL server: “嗯

我正在遵循《Rails食谱》一书中的食谱#3

这是我的database.yml文件:

demand:
  adapter: sqlserver
  host: 172.21.148.01
  port: 1433
  database: Demand
  username: DEapp
  password: @pp1user
  timeout: 5000
从rails控制台,当我使用
Demand.connection
测试连接时,我得到以下信息: (我知道addy和pw很好,因为我目前通过toad连接,还创建了“Demand”模型,所以rails将有一个对象)


有什么帮助吗?如果你愿意回答的话,这里有一个实用的程序员论坛:

我发现,因为外部DB用户密码是以
@
符号开头的,rails对此不满意,因为它认为它是和实例变量

我把PW换成了不启动的
@
,它连接得很好

    Drews-MacBook-Air:DE_App drewgilliam$ rails console
Loading development environment (Rails 3.1.3)
1.9.2p290 :001 > Externaldb.connection
  EXECUTE (36.7ms)  USE [DemandEstimator]
 => #<ActiveRecord::ConnectionAdapters::SQLServerAdapter version: 3.1.6, year: 2008, product_level: "SP1", product_version: "10.50.2500.0", edition: "Enterprise Edition (64-bit)", connection_options: {:adapter=>"sqlserver", :host=>"172.21.148.01", :port=>1433, :database=>"DemandEstimator", :username=>"DEapp", :password=>"demand_app_user", :timeout=>5000, :mode=>:dblib}> 
1.9.2p290 :002 >
Drews MacBook Air:DE_应用程序Drewgillam$rails控制台
加载开发环境(Rails 3.1.3)
1.9.2p290:001>外部数据库连接
执行(36.7ms)使用[DemanDestinator]
=>#“sqlserver”、:host=>“172.21.148.01”、:port=>1433、:database=>“DemanDestinator”、:username=>“DEapp”、:password=>“demand\u app\u user”、:timeout=>5000、:mode=>:dblib}>
1.9.2p290:002>

我发现,由于外部DB用户密码以
@
符号开头,rails对此不满意,因为它认为它是一个实例变量

我把PW换成了不启动的
@
,它连接得很好

    Drews-MacBook-Air:DE_App drewgilliam$ rails console
Loading development environment (Rails 3.1.3)
1.9.2p290 :001 > Externaldb.connection
  EXECUTE (36.7ms)  USE [DemandEstimator]
 => #<ActiveRecord::ConnectionAdapters::SQLServerAdapter version: 3.1.6, year: 2008, product_level: "SP1", product_version: "10.50.2500.0", edition: "Enterprise Edition (64-bit)", connection_options: {:adapter=>"sqlserver", :host=>"172.21.148.01", :port=>1433, :database=>"DemandEstimator", :username=>"DEapp", :password=>"demand_app_user", :timeout=>5000, :mode=>:dblib}> 
1.9.2p290 :002 >
Drews MacBook Air:DE_应用程序Drewgillam$rails控制台
加载开发环境(Rails 3.1.3)
1.9.2p290:001>外部数据库连接
执行(36.7ms)使用[DemanDestinator]
=>#“sqlserver”、:host=>“172.21.148.01”、:port=>1433、:database=>“DemanDestinator”、:username=>“DEapp”、:password=>“demand\u app\u user”、:timeout=>5000、:mode=>:dblib}>
1.9.2p290:002>

您必须使用混合模式(使用服务器ip地址)身份验证吗?或者你有使用windows身份验证的选项吗?不能使用windows身份验证,它是一个远程机器,实际上我认为它是一个linux机器,虚拟windows。您认为登录有问题吗?您必须使用混合模式(使用服务器ip地址)身份验证吗?或者你有使用windows身份验证的选项吗?不能使用windows身份验证,它是一个远程机器,实际上我认为它是一个linux机器,虚拟windows。你认为登录有问题吗?