I struggled with getting SQLServer to work with rails a couple years
ago. I can't speak to how easy or hard it is to do recently (sounds
just as painful), but here are the steps for how I did it then...they
might help. A note about step 2, at the time I used v0.1.0 of ruby-
dbi. ADO.rb continued to be included up through v0.2.2 and ADO.rb
from that version should still work but I think they stopped
supporting ADO after that. I know these steps work with SQLServer
2005, I'm curious to know if this also works with 2008. Also, I seem
to remember this only working with Ruby 1.8.6. I have since switched
database systems and haven't been motivated enough to figure out
SQLServer with newer code.
1. Install SqlServer adapter gem activerecord-sqlserver-adapter
(Only works with v1.0.0)
2. Download source distribution of Ruby-DBI from rubyforge.org/
projects/ruby-dbi/ (at the time, I used v0.1.0.
-copy the file lib/dbd/ADO.rb to Ruby/lib/ruby/site_ruby/1.8/DBD/ADO/
ADO.rb
database.yml file format:
development:
adapter: sqlserver
database: database_name
host: server_name
username: user_name
password: password
Also, you're using ODBC. I would recommend instead installing TinyTds
and using mode: dblib. This allows Rails to make a direct TDS
connection to your DB and bypass ODBC entirely.
I have tried both with an User DSN and a File DSN, and the User DSN used
the login on the system.
Also, you're using ODBC. I would recommend instead installing TinyTds
and using mode: dblib. This allows Rails to make a direct TDS
connection to your DB and bypass ODBC entirely.
Can I use TinyTds on a Windowsbox? I thought it was Linux-only.
I am using MSSQL and like you I had lots of trouble making it work but
I finally did get it to work. I am also using XP and here is my Ruby
and Rails environment:
Here is a list of the steps I took from beginning to end. You might
need to change/skip some of the steps. I hope it helps:
1. Install Ruby (1.8.6): Download Ruby
2. Install rubygems:
a. Download RubyGems | RubyGems.org | your community gem host (zip version)
b. Unpack to a directory and cd there
c. ruby setup.rb
3. Install rails: gem install rails –v=2.3.5
4. Install mongrel: gem install mongrel
5. Install mongrel service: gem install mongrel_service
6. Install SQL Server adapter: gem install activerecord-sqlserver-
adapter
7. Install ODBC gem: gem install odbc-rails
8. Install SQL Server Management utility (from Microsoft)
9. Create SQL Server DB (name 'give it a name here')
10. Create login in SQL Server ('give it a name here')
11. Create DB user ('give it a name here')
12. Create DSN in Windows:
a. Control Panel -> Adminstrative Tasks -> Data Sources (ODBC)
b. Click on System DSN -> Add
c. Select type SQL Server
i. Name: 'give it a name here'
ii. Description: 'give it a name here'
iii. Server: Server name (i.e.: 'Whatever name the DB has under
SQL Server Manangement here')
iv. Use SQL Authentication
A bit OT, but seeing as you mentioned it, as a Windows user that has
recently migrated my Rails apps to a Linux box, I can confirm what I
have frequently read on this group: Rails and Linux > Rails and
Windows.
I was brand new to Linux, and got everything up and running in no time
compared with my original struggles on Windows, and it looks like a
far better OS. If you haven't yet made the jump, I would recommend it.