Wednesday, April 11, 2012

Installing activerecord-sqlserver-adapter on Mac OS X Lion

I’m on Mac OS X 10.7.3 “Lion” and want to develop a Ruby on Rails 3.2.2 application using a MS SQL Server 2008 database. To do this I needed to install the activerecord-sqlserver-adapter which requires TinyTDS. While the gem install activerecord-sqlserver-adapter worked fine, the gem install tiny_tds failed to compile. It required a freetds component.

This took me a while and I ended up having to install Homebrew to get it to work. Here are the steps I took to get this working, hopefully it’ll save others the hour or so I spent trying to get it working.

  1. Install Homebrew Package Manager by using these instructions
  2. Install the FreeTDS component
    brew install freetds
  3. Install the TinyTDS gem
    gem install tiny_tds -- --with-freetds-include=/usr/local/include --with-freetds-lib=/usr/local/lib --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
  4. Now install the SQL Server ActiveRecord gem
    gem install activerecord-sqlserver-adapter

You’ll need to then setup your database.yml file accordingly:

  adapter: sqlserver
  database: mydb
  usernane: user
  password: s3cr3t


Anonymous said...

This got my tiny_tds installed. Thank you!

Anonymous said...

Scoured Google and this finally worked, thanks!