What's the right adapter to use for SQL Server?

I am porting a Rails app that is made up of 2 rails projects to SQL Server. The app already runs with MySQL and Oracle. One Rails project is the UI with a database that contains user/project specific data. The second Rails project is the database server for the main data. The UI makes REST calls to the database to get data to display. There is a list of product lines that is used on a search screen so the user chooses which product line to search. My problem is that with SQL Server as the database, about 80% of the time an exception gets thrown after the first product line data is returned. The message from the exception is "undefined method `name' for nil:NilClass".

This problem does not happen with MySQL nor Oracle as the database. So, it appears to be something to do with the database. I am using activerecord-sqlserver-adapter with a system DSN to connect to the database. I also had to move from Ruby 1.8.7 back to 1.8.6 to get the adapter to work at all. I have seen references to using ADO or ODBC instead.

So my questions are:

1. Has anybody else had a similar problem? 2. What database adapter is the proper one to use with SQL Server?

Thanks in advance! Norm

command0 wrote:

Aside from the migrations and database.yml, have you changed any other code in the app?

Nope, same code.

I am truly impressed with the portability of Rails apps! I did most of my development with JRuby in Ubuntu. The other developer used Ruby/Windows. The app runs on MySQL, Oracle, and SQL server from the same code base. Unless an app does something strange, other than getting a new environment set up and tweaking the config files, is about all you have to do.

So my questions are:

1. Has anybody else had a similar problem? 2. What database adapter is the proper one to use with SQL Server?

Thanks in advance! Norm

I am using only simple access to MS SQL I also find out how to call procedures. No problems so far.

ODBC is the only working way. Be it on Windows or Linux. Although it is not so trivial to install support on Linux it can be done (I am the proof :wink:

Search for "ruby odbc freetds" on google.

by TheR