在 Ruby on rails 中连接 Sql 服务器 [英] Connect Sql server in Ruby on rails

查看:53
本文介绍了在 Ruby on rails 中连接 Sql 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 ruby on rails 的新手.我想知道如何将 Sql server 连接到 rails 应用程序.

I am newbie to ruby on rails. I want to know how to connect Sql server to the rails application.

我在 Windows 环境中使用 RoR.是否有任何链接可以在 ROR 中建立与 SQL Server 的连接?

Iam working with RoR in windows environment. Is there any link to set up connection with SQL Server in ROR?

推荐答案

我没有在 Windows 上做过,但如果是在 Mac 上连接 postgresql 之类的,你必须:

I haven't done it on Windows, but if it's anything like connecting to postgresql on a mac you have to:

  1. 在本地运行 sql-server (http://msdn.microsoft.com/en-us/library/ms143219.aspx ?)
  2. 在您的 gemfile 中添加一个 gem 以允许 Rails 与之通信sql-server,可能是这样的:https://github.com/rails-sqlserver/activerecord-sqlserver-adapter |gem 'activerecord-sqlserver-adapter', '~>3.1.0'
  3. 更新 sql server 的 database.yml 文件,示例如下:设置Rails 与 sqlserver 一起工作(加上它也是答案)
  4. 然后您只需创建数据库并迁移它.在 Mac 上就像这个 rake db:create &&耙数据库:迁移
  1. Have sql-server running locally (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 '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)
  4. Then you would just create the db and migrate it. On a mac it's like this rake db:create && rake db:migrate

这篇关于在 Ruby on rails 中连接 Sql 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆