Hello Everyone,
I have been reading this mailing list for a while and am impressed with
the
generous help that many here are eager to provide. Perhaps someone will
be
able to shed some light on a configuration issue I am having. Thank you
in
advance for any assistance.
First, system setup details:
#System Setup#
- OS: Fedora Core 4 running in a VMWare box on Windows XP
- Database: MS SQL Server (newer/est version - can find out if
necessary)
running on a Windows server on our network - Access to SQL Server: Using unixODBC and FreeTDS to connect to the SQL
Server, I just set this up, so the versions are the newest - Rails Version: I keep updating every time DHH posts something on the
Rails
page, so I guess 1.0
#Error Message and Supporting Information#
When I access the action controller for a model I created I get the
following error
DBI::DatabaseError in Bug#index
S1000 (0) [unixODBC][FreeTDS][SQL Server]Unable to connect to data
source
I also used to get this error in my model unit test code if I didn’t
include
a manual connection with Model.establish_connection(…), but it went
away
yesterday when I twiddled around with the database.yml file a bit.
#Database Configuration#
Here is a cleaned up snippet from database.yml:
production:
adapter: sqlserver
mode: odbc
dsn: DSNNAME
username: WINDOMAIN\user
password: ********
test, development, and production have identical entries. My database
models are wrappers for non-rails tables and include primary key
redefinition, table definition, and foreign key relationships.
#Unit Test Example#
This is code from a working unit test that accesses the database:
require File.dirname(FILE) + ‘/…/test_helper’
class BugTest < Test::Unit::TestCase
def setup
@bug = Bug.find(1)
end
def test_read
assert_equal 1, @bug.id
puts "Category => " + @bug.category.sCategory
puts "Project => " + @bug.project.sProject
puts "Area => " + @bug.area.sArea
puts "PersonOpenedBy => " + @bug.person_opened_by.sFullName
puts "PersonAssignedTo => " + @bug.person_assigned_to.sFullName
end
end
This works perfectly and I assume must be using my database.yml for
connection info.
#Action Controller Code#
class BugController < ApplicationController
def index
@bugs = Bug.find(1)
end
end
#Summary#
I can access the database using a unit test but not through a web
browser
against my action controller.