exceptionz

Thoughts on Technology, Methodology and Programming.

Archive for November 1st, 2006

Rails scaffold method problems (actually connection)

Posted by Marcus Wyatt on 1 November 2006

I’m trying out Ruby in Steel the past week and where pulling my hair out because the scaffold method did not work. The database was hosted on a SQL2005 server and I did not think you need to do anything special to use Ruby in Steel against SQL.

So after a couple of hours trying to solve the problem, I decided to try my project against a MySQL database and scaffold worked. So I figured that there must be a problem with rails connecting to the sql database.

If you get the following message “identical test/fixtures/posts.yml is not a class/module” when running script/generate scaffold, then you have a problem connecting to the sql database (that’s of course if you using sql as your data store).

I found a solution to the SQL2005 connection problem on a fellow wordpress blog.

Just in ram posted the following:

It appears rails does not connect to MS SQL Server right out of the box. You need to do the following to get the connection to work:

NOTE: These instructions are a tweaked version of http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLServer

Get the latest source distribution of Ruby-DBI and copy the file:

bdi-0.1.0/lib/dbd/ADO.rb

to:

c:/ruby/lib/ruby/site_ruby/1.8/DBD/ADO/ADO.rb

NOTE: The ADO directory does not exist on a standard install, you will need to create it.

Then simply set up your railsapp/config/database.yml

Here’s an example for reference:

development:
  adapter: sqlserver
  database: database_name
  host: server_name
  username: user_name
  password: your_pw_here

Thanx… just in ram

Posted in RoR | 1 Comment »