# ODBC Adapter woes

**URL:** <https://www.ruby-forum.com/t/odbc-adapter-woes/87756>\
**Category:** Rails\
**Created:** [March 5, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/odbc-adapter-woes/87756 "2007-03-05T19:30:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9e8a1a/32.png) [@rickf](https://www.ruby-forum.com/u/rickf)\
**Post date:** [March 5, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/odbc-adapter-woes/87756/1 "2007-03-05T19:30:54Z")

</div>

Hi All,

I am running into a little issue the ODBC adapter:

rails: 1.2  
ruby: 1.8.4  
ODBC ruby binding: .0997  
Rails ODBC adapter: 1.4

I have added the ruby bindings to the /ruby/1.8/i386-msvcrt  
and used gem to install the ODBC adapter

I updated the enviroment.rb

when I run  
ruby -e ‘require “odbc”’ it appears to correct (no error response)

1. Is my understanding correct the Rails ODBC adapter will abstract the  
SQL calls the same as the current Adapter does when a native DB is used?

2. Also, how do I configure the database.yml to use the new ODBC driver?

Any help is greatly appreciated.

Error output below:

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active\_record/connection\_adapters/abstract/connection\_specificati  
on.rb:14: undefined method `cattr_accessor' for ActiveRecord::Base:Class (NoMethodError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active\_record/connection\_adapters/abstract\_adapter.r  
b:10  
from  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' from c:/ruby/lib/ruby/gems/1.8/gems/odbc-rails-1.4/lib/active_record/connection_adapters/odbc_adapter.rb:27 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/odbc-rails-1.4/lib/odbc\_adapter.rb:28  
from  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:33:in  
`require' from C:/3.0maintrunk/ocsuite/webui/config/environment.rb:30 ... 6 levels... from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:83:in`run’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in  
`run’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel\_rails:243  
from c:/ruby/bin/mongrel\_rails:18

Thanks again!!!

---

<div class="post-metadata">

**Author:** ![rickf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9e8a1a/32.png) [@rickf](https://www.ruby-forum.com/u/rickf)\
**Post date:** [March 7, 2007, 11:06am UTC](https://www.ruby-forum.com/t/odbc-adapter-woes/87756/2 "2007-03-07T11:06:48Z")

</div>

Rick,

You can find detailed installation and configuration information at  
[http://odbc-rails.rubyforge.org](http://odbc-rails.rubyforge.org).

After installing the gem, enable loading of the adapter by editing  
your Rails project’s config/environment.rb script:

- Add a require to your config/environment.rb immediately after the  
line  
require File.join(File.dirname( **FILE** ), ‘boot’)  
i.e.  
require File.join(File.dirname( **FILE** ), ‘boot’)  
require ‘odbc\_adapter’

You’ll need to define an ODBC DSN for your data source, then reference  
this in your database.yml file.  
Your database.yml file should contain something similar to:

development:  
adapter: odbc  
dsn: b606\_vos\_localhost\_rails\_dev  
username: rails\_dev  
password: rails\_dev  
emulate\_booleans: true  
trace: false

with a similar entry for your test: environment.

The emulate\_booleans entry isn’t needed if the database has a native  
BOOLEAN type. See the ‘Usage Information’ and ‘Database Specific  
Notes’ sections of [http://odbc-rails.rubyforge.org](http://odbc-rails.rubyforge.org).

The odbc-rails gem includes detailed RDoc information. (Run gem\_server  
and point your browser to [http://localhost:8808](http://localhost:8808) to see the local RDoc  
documentation)

Also, ensure you set the RUBYOPT environment variable:  
set RUBYOPT=-rubygems  
Otherwise you may see a “undefined method `cattr\_accessor’” error  
message.

Hope this helps

Carl Blakeley
