0

I have in my initializers/my_initializer.rb:

ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::NATIVE_DATABASE_TYPES[:string] = {
  name: 'varchar',
  limit: 191
}

Why does it throw the error: uninitialized constant ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter (NameError) when I try to start the server?

I get the same error even if I put the following in the 1st line of the initializer:

require 'active_record'

However, when I put the below statement in the 1st line of the initializer, everything works fine:

require '/home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb'

Why does it not work with require 'active_record'?

TomDogg
  • 3,803
  • 5
  • 33
  • 60
  • I'm guessing ActiveRecord does not require the mysql adaptar by default since you may not want to use MySQL as the database adaptar (like, you want pg for example). – arieljuod Nov 13 '18 at 21:21
  • @arieljuod Thanks. Assuming this is the only issue, I assume the correct way to require the mysql adapter would be: `require 'active_record/connection_adapters/abstract_mysql_adapter.rb'`? – TomDogg Nov 13 '18 at 21:29
  • Hmmm I'm not sure if it is or isn't the correct way, but I guess it's ok if it works. You can skip the ".rb" extension on the require. – arieljuod Nov 14 '18 at 04:14

0 Answers0