简体   繁体   English

在rails上连接Ruby中的Sql server

[英]Connect Sql server in Ruby on rails

I am newbie to ruby on rails . 我是ruby on rails上的ruby on rails新手。 I want to know how to connect Sql server to the rails application. 我想知道如何将Sql server连接到rails应用程序。

Iam working with RoR in windows environment. 我在Windows环境中使用RoR。 Is there any link to set up connection with SQL Server in ROR? 是否有任何链接在ROR中设置与SQL Server连接?

I haven't done it on Windows, but if it's anything like connecting to postgresql on a mac you have to: 我还没有在Windows上完成它,但如果它类似于连接到mac上的postgresql,你必须:

  1. Have sql-server running locally ( http://msdn.microsoft.com/en-us/library/ms143219.aspx ?) 让sql-server在本地运行( http://msdn.microsoft.com/en-us/library/ms143219.aspx ?)
  2. Add a gem to your gemfile that will allow Rails to talk to sql-server, probably this: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter | 在gem文件中添加一个gem,允许Rails与sql-server通信,可能是这样的: https//github.com/rails-sqlserver/activerecord-sqlserver-adapter | gem 'activerecord-sqlserver-adapter', '~> 3.1.0'
  3. Update your database.yml file for sql server, example here: Setting up Rails to work with sqlserver (plus it's also the answer) 更新sql server的database.yml文件,例如: 设置Rails以使用sqlserver (加上它也是答案)
  4. Then you would just create the db and migrate it. 然后,您只需创建数据库并进行迁移。 On a mac it's like this rake db:create && rake db:migrate 在mac上就像这个rake db:create && rake db:migrate

使用此链接配置SQL Server

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

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