logo

RubyOnRails using MSSQL Server and FreeTDS (Part 2)

logo

So here’s the rest of my getting Rails to connect to MSSQL experience … (See Part 1)

Since I used Hivelogic’s setup (you can also install from Darwin .. which I’ll probably install on my laptop which I’ve already done and will forever ALWAYS do) for my Ruby and Rails installation, I just went back to my usr/local directory to do the rest of the work. I should also note that you’ll need to have Ruby and Rails installed at this time in order for the commands to actually work (yea, I know it’s obvious, but just needed to say).

 

To install the rubi-dbi libraries ,the listed directions didn’t seem to work correctly so I tried:

1
2
curl -O http://www.ch-werner.de/rubyodbc/ruby-odbc-0.996.tar.gz  
tar vxzf ruby-odbc-0.996.tar.gz

Quick Note: if for any reason this doesn’t work through the terminal or you can’t get terminal to download the file, just download the files directly using your web browser, extract them, and move the files to your usr/local directory. Sure, it’s not cool “terminal-ly” but it works.

Now install every thing:

1
2
3
4
5
cd ruby-odbc-0.996
ruby extconf.rb
make
sudo make install
cd ..

Finally, we’ll install the ruby-odbc libraries:

1
2
3
4
5
6
curl -O 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

Yea! Now you can just provide the details in your conf/database.yml file and you’ve got a working RubyOnRailsOnMSSQL app!

1
2
3
4
5
6
development:
  adapter: sqlserver
  mode: odbc
  dsn: MyDSN
  username: USERNAME
  password: PASSWORD

Of course there’s always the question of how well will it run? I’ll have to see and report about it in the future. And one last caveat… the Rails Wiki mentiond that when you run rake from your app root you’ll get this error:

1
2
3
4
sh: line 1: scptxfr: command not found
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21: command not found:
                                                  scptxfr /s  /d  /I /F db /q /A /r
sh: line 1: osql: command not found

Everything is OK though … it’s just assuming you’re accessing from a PC which is where those files come from.

Technorati Tags: , ,

View Comments to “RubyOnRails using MSSQL Server and FreeTDS (Part 2)”

  1. mike says:

    A quick tip for anyone surfing in from Google and using these instructions: The version of ruby-odbc listed (0.996) occasionally crashes with the error “[RubyODBC]No data found”. To fix this, upgrade to 0.9993.

    Thanks for this article!

  2. dalager says:

    followup to mike:
    Find the newest ruby-odbc version here:
    http://raa.ruby-lang.org/project/ruby-odbc/

Leave a Reply

You must be logged in to post a comment.

blog comments powered by Disqus
logo
logo
Powered by Wordpress