Forum: Ruby on Rails ODBC Adapter woes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
903de3fe51f14392609e28e82e1b1c6c?d=identicon&s=25 Rick Fiorentino (rickf)
on 2007-03-05 19:30
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!!!
Ed1715615ad502bb555a2200a61caa62?d=identicon&s=25 cms (Guest)
on 2007-03-07 11:06
(Received via mailing list)
Rick,

You can find detailed installation and configuration information at
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.

The odbc-rails gem includes detailed RDoc information. (Run gem_server
and point your browser to 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
This topic is locked and can not be replied to.