在MS SQL Server 2005中使用Rails 2.x [英] Using Rails 2.x with MS SQL Server 2005
问题描述
这里有人在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:
- 确保已安装Java 6
- 按照 JRuby网站 上的说明安装JRuby.
- 使用gem(
jruby -S gem install rails
)安装Rails - 下载 Microsoft的SQL Server JDBC驱动程序( 2.0版)
- 解压缩Microsoft的SQL Server驱动程序
- 找到sqljdbc4.jar并将其复制到JRuby的lib目录
-
jruby -S gem install activerecord-jdbcmssql-adapter
- 创建Rails项目(
jruby -S rails hello
) - 在database.yml中放置正确的设置(以下示例)
- 您都准备好了!尝试运行
jruby script/console
并创建模型.
- Make sure Java 6 is installed
- Install JRuby using the instructions on the JRuby website
- Install Rails using gem (
jruby -S gem install rails
) - Download the UNIX package of Microsoft's SQL Server JDBC driver (Version 2.0)
- Unpack Microsoft's SQL Server driver
- Find sqljdbc4.jar and copy it to JRuby's lib directory
jruby -S gem install activerecord-jdbcmssql-adapter
- Create a rails project (
jruby -S rails hello
) - Put the proper settings in database.yml (example below)
- 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屋!