title: Rails 4 ODBC Connection
body: <p>I've been using Ruby successfully to connect to an external IBM DB2 odbc database using a third-party driver. However, when I try to do the same thing in Rails, an error is thrown:</p>
  
  <pre><code>IM003 (160) Specified driver could not be loaded due to system error 182
  </code></pre>
  
  <p>I've tried these gems (odbc-rails uses development.rb, same result):</p>
  
  <ul>
  <li>gem 'rails-dbi'</li>
  <li>gem 'dbd-odbc'</li>
  <li>gem 'ruby-odbc'</li>
  <li>gem 'odbc-rails'</li>
  </ul>
  
  <p>Here is the line of code that throws the error:</p>
  
  <pre><code>DBI.connect("DBI:ODBC:My_ODBC_Connection", username, password)
  </code></pre>
  
  <p>I can run this line of code at the Ruby console, but not at the Rails console with the same Ruby version. I am using Windows 8.1</p>
  
  <p>I have given full permissions to the folder containing the library. Also tested running commands in administrative mode for the CLI.</p>
  
  <p>I have looked up Rails guides to see if there was a security feature blocking the driver from being loaded in Rails and it seems the issue resides with Rails somewhere.</p>
  
  <p>If anybody has any ideas, I would be very grateful.</p>