在MS SQL Server 2005中使用Rails 2.x [英] Using Rails 2.x with MS SQL Server 2005

查看:69
本文介绍了在MS SQL Server 2005中使用Rails 2.x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有人在Rails 2.x上使用MS SQL Server 2005有积极的经验吗?

Does anybody here have positive experience of working with MS SQL Server 2005 from Rails 2.x?

我们的开发人员使用Mac OS X,我们的产品在Linux上运行.出于遗留原因,我们应该使用MS SQL Server 2005.

Our developers use Mac OS X, and our production runs on Linux. For legacy reasons we should use MS SQL Server 2005.

我们正在使用ruby-odbc并遇到各种问题,太令人沮丧了,无法在此处列出.我觉得我们做错了什么.

We're using ruby-odbc and are running into various problems, too depressing to list here. I get an impression that we're doing something wrong.

我说的是不妥协的用法,即迁移和全部使用.

I'm talking about the no-compromise usage, that is, with migrations and all.

谢谢

推荐答案

您是否考虑过使用JRuby? Microsoft具有用于SQL Server的JDBC驱动程序,该驱动程序可以在UNIX上运行变体(纯Java AFAIK).今天,我能够使用JRuby和Rails 2.1进行2.0技术预览.我还没有尝试过迁移,但是到目前为止,驱动程序似乎运行良好.

Have you considered using JRuby? Microsoft has a JDBC driver for SQL Server that can be run on UNIX variants (it's pure Java AFAIK). I was able to get the 2.0 technology preview working with JRuby and Rails 2.1 today. I haven't tried migrations yet, but so far the driver seems to be working quite well.

下面是如何使其工作的示意图:

Here's a rough sketch of how to get it working:

  1. 确保已安装Java 6
  2. 按照 JRuby网站
  3. 上的说明安装JRuby.
  4. 使用gem(jruby -S gem install rails)安装Rails
  5. 下载 Microsoft的SQL Server JDBC驱动程序( 2.0版)
  6. 解压缩Microsoft的SQL Server驱动程序
  7. 找到sqljdbc4.jar并将其复制到JRuby的lib目录
  8. jruby -S gem install activerecord-jdbcmssql-adapter
  9. 创建Rails项目(jruby -S rails hello)
  10. 在database.yml中放置正确的设置(以下示例)
  11. 您都准备好了!尝试运行jruby script/console并创建模型.
  1. Make sure Java 6 is installed
  2. Install JRuby using the instructions on the JRuby website
  3. Install Rails using gem (jruby -S gem install rails)
  4. Download the UNIX package of Microsoft's SQL Server JDBC driver (Version 2.0)
  5. Unpack Microsoft's SQL Server driver
  6. Find sqljdbc4.jar and copy it to JRuby's lib directory
  7. jruby -S gem install activerecord-jdbcmssql-adapter
  8. Create a rails project (jruby -S rails hello)
  9. Put the proper settings in database.yml (example below)
  10. You're all set! Try running jruby script/console and creating a model.


    development:
      host: localhost
      adapter: jdbc
      username: sa
      password: kitteh
      driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
      url: jdbc:sqlserver://localhost;databaseName=mydb
      timeout: 5000

注意:我不确定您是否可以将Windows身份验证与JDBC驱动程序一起使用.您可能需要使用SQL Server身份验证.

Note: I'm not sure you can use Windows Authentication with the JDBC driver. You may need to use SQL Server Authentication.

祝你好运!

这篇关于在MS SQL Server 2005中使用Rails 2.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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