DBI: connect succeeds in IRB, fails in Rails

require ‘dbi’ # 0.4.2
dbh = DBI.connect(‘DBI:ODBC:PACS’, ‘username’, ‘password’)

This works in IRB; in Rails it fails (taken from Rails console):
DBI::InterfaceError: Unable to load driver ‘ODBC’ (underlying error:
uninitialized constant DBI::DBD::ODBC)
from C:/scripts/Rads/vendor/gems/dbi-0.4.2/lib/dbi.rb:300:in
load_driver' from c:/ruby/lib/ruby/1.8/monitor.rb:242:insynchronize’
from C:/scripts/Rads/vendor/gems/dbi-0.4.2/lib/dbi.rb:242:in
load_driver' from C:/scripts/Rads/vendor/gems/dbi-0.4.2/lib/dbi.rb:160:in_get_full_driver’
from C:/scripts/Rads/vendor/gems/dbi-0.4.2/lib/dbi.rb:145:in
`connect’
from (irb):2

I haven’t found anything online that was a substantial help :confused:

Oh – Ruby 1.8.7, and I can connect by writing a small script and
launching it with Ruby (same version of Ruby that Rails uses).

gem install dbd-odbc

(who knows why it worked without me doing that beforehand; maybe some
gem update and it forgot that this existed, or overwrote files… ?)

And a reinstallation of ruby-odbc :
http://www.ch-werner.de/rubyodbc/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs