Ruby on Rails on OS X with SQL Server
Yeah, I know. But hey, sometimes you gotta live on the edge.
If you don’t already have ODBC talking to MS SQL Server on your Mac, you’ll need to get that set up and tested first.
We need a couple of extra pieces of software to let Rails talk to the server via ODBC.
Ruby-ODBC: cd /tmp wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.996.tar.gz tar vxzf ruby-odbc-0.996.tar.gz cd ruby-odbc-0.996 ruby extconf.rb make sudo make install
Ruby DBI ODBC driver: cd /tmp wget http://rubyforge.org/frs/download.php/655/ruby-dbi-all-0.0.23.tar.gz tar vxzf ruby-dbi-all-0.0.23.tar.gz cd ruby-dbi-all ruby setup.rb config –with=dbi,dbd_odbc ruby setup.rb setup sudo ruby setup.rb install
The format of the database.yml will be slightly different than the norm:
development:
adapter: sqlserver
mode: odbc
dsn: the_dsn_you_created_and_tested_in_iodbc_administrator
username: username
password: password
There is currently a bug in script/console that will throw a BUS error when trying to access the database, but everything works outside of the console.
You should also be aware that SQL Server isn’t currently supported very well in Rails. I ran into a couple of bugs today and submitted patches for them: