Using ActiveRecord to connect to Sybase Adaptive Server Anywhere on Windows

Just don’t ask why I know this. Please. It’s making me cry.

Install Ruby using the One Click Installer.
Install the ODBC module (by copying the SO files into the c:\Ruby\1.8\i386-mingw32 folder).
Install the ActiveRecord ODBC adapter (gem install activerecord-odbc-adapter).
Edit C:\Ruby\lib\ruby\gems\1.8\gems\activerecord-odbc-adapter-2.0\ lib\active_record\connection_adapters\odbc_adapter.rb – look for line 1588.
Change the line from elsif dbmsName =~ /SQLAnywhere/i to elsif dbmsName =~ /SQLAnywhere/i or dbmsName =~ /adaptiveserveranywhere/i

Write some test code – something like:


require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(:adapter => :odbc, :dsn => 'mydsn', :username => 'myusername', :password => 'mypassword')

class Whatever < ActiveRecord::Base

end

Whatever.all

Run this - hopefully you should get no errors.
Then sit down and have a long think about what the hell you are doing.

Tags: , , , ,

This entry was posted on Monday, December 21st, 2009 at 9:18 pm and is filed under General, Ruby on Rails and Software Development. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.