Quick and dirty Rails on MS SQL deployment guideline

The full guide to deploying a Rails application which uses MS SQL Server on Linux can be found on the rails wiki. Note that I worked my way through this when using MS SQL Server 2000, not 2005.
The idea is that you use these notes as a reference and look at the full guide for details.

Read the notes at the end of the wiki page first as the locations of various config files and .so files depends on your distro. That way, you have these potential stumbling blocks in mind when following the full guide. Also note that the wiki is fairly unstructured with numerous edits and comments. Don't expect Wikipedia standards.

I would recommend building unixODBC and freeTDS from source as opposed to apt-get or yum

Outline:
  1. Export env vars for ODBCINI, ODBCSYSINI and FREETDSCONF. You may have to create symlinks to the odbc.ini and odbcinst.ini files later from the user ~/ dir. See unixODBC configuration. For FreeTDS, symlink to freetds.conf from /usr/local/etc unless it already in that dir. See FreeTDS configuration.
  2. Install unixODBC-devel, unixODBC verify where libtdsodbc.so ends up
    • if you can't fint libtdsodbc.so after, then compilation has failed
    • remember where you configured the location of --sysconfdir
  3. Install FreeTDS (with compile time configuration set to TDS version 8.0, or do this later in freetds.conf)
  4. Test using tsql and isql
  5. Install Ruby ODBC latest (0.9995, and you will need the ruby-devel packages installed to compile)
  6. Install Ruby DBI latest (0.1.1, http://rubyforge.org/frs/download.php/12368/dbi-0.1.1.tar.gz)
  7. Test connection using using irb; run the next two lines - if no error then we're good
    • require "dbi"
    • dbh = DBI.connect('dbi:ODBC:YOUR_DB_DEFINITION_NAME', 'USERNAME', 'PASSWORD')
  8. Install RubyWorks, follow the guide to install your load balanced mongrel cluster. This should take 5 minutes. Then go on to optionally set up a web server of your choice. If connections to the DB fail only for the 'rails' user created by RubyWorks, make sure that all the config files are in their default locations - see (1).
That's it.

No comments: