The blog of Rahoul Baruah from 3hv Ltd

What's going on?

My name is Rahoul Baruah (aka Baz) and I'm a software developer in Leeds (England).

This is a log of things I've discovered while writing software in Ruby on Rails. In other words, geek stuff.

However, I've decided to put this blog on ice - I would ask you to check out my business blog here (or subscribe here).

02 December, 2005

Setting up Rails for SQL Server

First of all you need to grab the ADO file (as described here).

Then set up your config/database.yml to look something like:

adapter: sqlserver
server: server_name
database: database_name
host: DBI:ADO:Provider=SQLOLEDB;Data Source=server_name;Initial Catalog=database_name;User Id=user_name;Password=your_pw_here;
username: user_name
password: your_pw_here

Some of these values are repeated as it helps the various parts pull out the information they need without the whole connection string getting in the way.

Speaking of which, we need to alter your rakefile:

In lines 160 and 161 change




In line 139 change




The following are patches that I will submit to when I figure out what I need to do ...

In /ruby/lib/ruby/gems/1.8/gems/actionwebservice-version/lib/action_web_service/casting.rb

Look for line 53 – above

elsif signature_type.structured?

insert the following lines:

elsif value true || value false
cast_base_type(value, :bool)

This is because ActiveWebService does not know how to deal with booleans (which MySQL does not use, but SQL Server does, with its BIT fields).

In /ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/connection_adapters/sqlserver_adapter.db

Look for line 61 – above

when /bit/i then :boolean

insert the following lines:

when /uniqueidentifier/i then :string

This is because ActiveWebService does not know how to deal with uniqueidentifier fields (which MySQL does not have). Luckily SQL Server is quite happy to accept strings for uniqueidentifiers and converts them implicitly - so we just tell the SQL Server Adapter to use strings whenever it comes across a uniqueidentifier.

No comments:

eXTReMe Tracker