rails-sqlserver/activerecord-sqlserver-adapter — Issue #168: "Server name not found in configuration files"
Author: lospalmer
Created: 2012-02-27 21:37:54+00:00
State: open

Ken,
I gotta tell ya... This is a great tool. However...

I got it to work, once, literally once. I was able to see my objects from my MSSQL database. After that 1 time, I've seen an array of problems with my connection. The latest trend would be the error depicted in the topic. I've been wrestling with this for 5 days already and frankly I'm so frustrated that my jaws hurt from clenching. I know there is plenty of information out there but I have not been able to find a good, simple, straightforward way to implement this tool. Perhaps you can aid me. Btw, I'm sorry you've had to answer 1M similar posts.

I'm trying to launch an app that does basic reporting (hence no inserting/manipulating records on the db just reading) for people at the company I work for to get some info from a legacy DB that has a pretty complex schema. So we've created views to pool the info together and just make 1 request with 1 transaction to the db server and get all the info we need. Now, that being said... It's so simple that I'm using basically a bare bones implementation of Rails 3.1, Ruby 1.9.2. Here is what I'm doing:

I'm in a Windows machine at the moment ( I know what you're thinking... I'm trying to help this company open up to open source tech, hence the reason I want to use RoR to show executive management a quick implementation of a reporting tool... blah blah)

Gemfile:
gem 'sqlite3'

# MSSQL DB Adapter and DBLIB Connection tool
# gem 'tiny_tds', '~> 0.5.1'
# gem 'activerecord-sqlserver-adapter', '~> 3.1.1'
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'

#Parse .xls
gem "spreadsheet", "~> 0.6.5.9"
gem "roo", "~> 1.10.1"

gem 'ruby-debug19'

database.yml:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

dtmf_dev:
adapter: sqlserver
mode: dblib
dataserver: server_name
host: localhost
database: dev_db_name
username: username
password: username
port: 1433
timeout: 5000

model:
establish_connection ('dtmf_dev')
set_table_name :db_table_name
set_primary_key 'view_unique_identifier'

Then I call my objects from the controller to send 'em over to the view. That is basically going to display a jQuery widget-type grid with all the info/columns of the records. It's really that simple. So... Why am I seeing this barrage of errors, ranging from server names not being in some files, Active servers not connected, user logins failing...

Is there a simple way of calling the DB configuration in the database.yml file from the Model so that I can use it in my controllers?