MS SQL server connection

I noted the couple of steps I need to connect to a Microsoft SQL server in my Rails Tiddly Wiki under “MicrosoftSQL”. I’ve need to fire up a Rails development system on another PC and have found that the gems have moved on, and these instructions are now out of date (as are most of the instructions I found via a google search). In particular, Ruby-DBI no longer includes ADO.rb.

I was able to get my system working – that is, a connection to a SQL 2005 server from a Rails application created with a previous SQL server set up and set up on an XP Pro PC – by doing the following:

  gem install activerecord-sqlserver-adapter
  gem install rails-sqlserver-2000-2005-adapter -s http://gems.github.com
  gem install dbd-odbc

The first step is the same as previously. The current gem now installs a Ruby-DBI gem – but the version without ADO.rb (dbi-0.4.1) – as well as the activerecord-sqlserver-adapter gem.

The other two steps were taken from the Rails Wiki. To be honest I’m not sure they are needed.

I think the key step is this next one:

I then went to the gems directory (C:\ruby\lib\ruby\gems\1.8\gems) and deleted dbi-0.4.1 directory, and replaced it with dbi-0.2.2 which I downloaded from RubyForge. My system then worked correctly.

I’ve tried gem uninstall to remove dbi-0.4.1., but this doesn’t work. activerecord-sqlserver-adapter sees it as a dependant service and won’t work if dbi is uninstalled via gem uninstall. Deleting the folder works.

This entry was posted in Ruby. Bookmark the permalink.