Getting Rails 2.0 and MS SQL Server Talking
December 17th, 2007
With version 2.0 of Rails, getting it talking to SQLServer has become a whole lot easier.
Today I had to get a different Windows computer hooked up as a development system to talk to our Rails installation and the Development SQL Server.
I started trawling through the online documentations and thought, “This must be easier”.
So, I went off to get the latest One Click Ruby Installer for Windows (1.8.6.26) and downloaded it.
After installing this, I did the following:
c:\> gem install rails c:\> gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org
And then configured up my database.yml file like so:
1 2 3 4 5 |
development: adapter: sqlserver mode: ODBC dsn: app_development host: 127.0.0.1 |
Added similar entries for production and test and started my app…
AND IT WORKED!!!!!!
This is really cool! Lots easier than plugging in this ODBC connecter and that Ruby DBI… the one click installer has it all already installed.
Anyway, thought y’all might like to know.
Mikel
January 16th, 2008 at 04:02 AM
Thanks for posting this explanation. I’m running into a problem with the SQL Server adapter that I can’t seem to find any information on anywhere else. I’m moving databases back and forth between SQL Server and MySQL using rake (db:backup:write to backup, db:backup:write to restore) but the adapter can’t seem to handle dates prior to 1970. This is a problem because I’m dealing with dates of birth in the system and they’re getting lost along the way. Have you bumped up against the issue? Do you have any ideas for where I might go to resolve the issue?
January 17th, 2008 at 12:50 AM
Gavin,
Actually, I did have this exact problem and fixed it for myself, then I found it was patched around the same time.
Have a look at this entry for the details.
Mikel