rahrahruby rahrahruby - 2 months ago 12
Ruby Question

cannot load such file -- mysql12 (LoadError)

I have a ruby script that I have written and I am trying to use if to write to an active record database that I have created. When I add a require 'mysql12' to the file I get the following error:


.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:106:in `require': cannot load such file -- mysql12 (LoadError)


When I do a

gem list | grep mysql
activerecord-mysql2-adapter (0.0.3)
mysql2 (0.3.11)


it shows that the mysql12 gem is installed.

My database.yml file for the project looks like this:

production:
adapter: mysql2
encoding: utf8

vee vee
Answer

When I add a require 'mysql12' to the file I get the following error:

.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:106:in `require': cannot load such file -- mysql12 (LoadError).

As commented above updating the require statement to require 'mysql2' in your ruby script should fix the error.