Rails 5,Monkeypatch出现模型错误

时间:2018-06-21 00:50:26

标签: ruby-on-rails

我在Ruby on Rails中得到了一个全新的应用程序,该应用程序使用rails 5.1和ruby 2.3.1

我所有的模型都遵循模式

class Address < ApplicationRecord
  ##### AUDITED
  audited

  ##### GEOCODE
  reverse_geocoded_by :lat, :lng

  ##### RELATIONSHIPS
  belongs_to :city
  belongs_to :addressable, polymorphic: true, optional: true, touch: true
end

继承自ApplicationRecord

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true

  ##### SCOPES
  default_scope { where(deleted: false) }

  ##### SOBRESCREVENDO O MÉTODO DESTROY DO ACTIVERECORD
  def destroy
    run_callbacks(:destroy)
    self.update_attribute(:deleted, true)
  end
end

在开发ENV上一切正常,但是要在生产环境中工作,我需要将config.eager_load = false的{​​{1}}设置为false。如果我不这样做,就会出现这种错误:

  

TypeError:地址类的超类不匹配

没有其他config/environments/production.rbApplicationRecord类,怎么了?

0 个答案:

没有答案