Custom Model - “no such file to load — odbc”

2019-07-27 17:46发布

问题:

I'm trying to create a custom model to interface with a database that isn't supported navtively by Rails or through the OpenLink ODBC driver. For some reason, I'm getting the following error:

no such file to load -- odbc

I'm at a lost as to why this is occurring as the ruby-odbc gem is in the GEM_PATH and I have a small script that tests this to ensure that the connection works and it worked perfectly. Does Rails ignore the gem_path? Is there something else I need to configure? I checked the GEM_PATH in Rails by writing it out to the browser and it matches what I saw in a terminal window.

FYI: I'm using rvm to manage ruby and all of my gems. Not sure if this makes any difference, though it really shouldn't from what I can tell.

回答1:

Does your Gemfile include something like the following

gem 'ruby-odbc'