Rails 5.2:从初始化程序要求ActiveRecord

时间:2018-11-13 21:03:14

标签: ruby-on-rails activerecord ruby-on-rails-5 initializer

我有initializers/my_initializer.rb

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

为什么在我尝试启动服务器时抛出错误:uninitialized constant ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter (NameError)

即使将以下内容放在初始化程序的第一行中,我也会遇到相同的错误:

require 'active_record'

但是,当我将以下语句放在初始化的第一行时,一切正常:

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'

为什么它不能与require 'active_record'一起使用?

0 个答案:

没有答案