简体   繁体   English

如何使Ruby on Rails使用SQL Server 2008生成模型

[英]How to get Ruby on Rails to generate a model using sql server 2008

Ruby version: 3.0.2 Rails: 1.9.2 OS: windows 7 DB: sql server 2008 (r2) Ruby版本:3.0.2 Rails:1.9.2 OS:Windows 7 DB:SQL Server 2008(R2)

I tried to execute the following command: rails generate model product 我尝试执行以下命令:Rails生成模型产品

The error I get can be seen here: pastebin.ca/1965168 我得到的错误可以在这里看到:pastebin.ca/1965168

I tried to follow these two sites: rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html 我尝试关注以下两个站点:rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html

www.lostechies.com/blogs/rhouston/archive/2008/05/03/connecting-activerecord-to-sql-server.aspx www.lostechies.com/blogs/rhouston/archive/2008/05/03/connecting-activerecord-to-sql-server.aspx

I ran the following: gem install activerecord-sqlserver-adapter which appeared to install the gem and i've confirmed that there is an activerecord directory in my ruby installation. 我运行了以下命令:gem install activerecord-sqlserver-adapter,它似乎是在安装gem的,并且我已经确认在我的ruby安装中有一个activerecord目录。

I also ran:gem install dbi-0.4.3 我也跑了:gem install dbi-0.4.3

my database.yml file contains the following: adapter: sqlserver mode: odbc dsn: sqlTest_development host: localhost username: sqlTest password: pool: 20 timeout: 50000 我的database.yml文件包含以下内容:适配器:sqlserver模式:odbc dsn:sqlTest_development主机:localhost用户名:sqlTest密码:池:20超时:50000

If you need any other information please let me know. 如果您需要其他任何信息,请告诉我。 I've tried other sites but people just tell me I should switch to Linux which isn't very helpful. 我尝试过其他站点,但人们只是告诉我,我应该切换到Linux,这不是很有帮助。

why not just use active record? 为什么不只使用活动记录? Sorry not as familiar with SQL Server Connection.. 抱歉,对SQL Server连接的了解不那么丰富。

:adapter => "sqlserver",
:host => ".\\SQLEXPRESS",
:database => "MyDB",
:username => "sa",
:password => "sa"

here's an example with odbc: http://github.com/aslakhellesoy/activerecord-sqlserver-adapter/blob/master/test/connections/native_sqlserver_odbc/connection.rb 这是odbc的示例: http : //github.com/aslakhellesoy/activerecord-sqlserver-adapter/blob/master/test/connections/native_sqlserver_odbc/connection.rb

But I think this link to the actual gem will help the most: http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation---Windows 但我认为此链接到实际的gem会最大程度地帮助您: http : //github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation---Windows

我很遗憾地说,从2008年开始的指南是旧的...(sqlserver适配器不再需要dbi)正如Nick所说的:转到Github上activerecord适配器的Wiki

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM