Project

General

Profile

« Previous | Next » 

Revision d81dc2a0

Added by Peter Lehwess about 6 years ago

Fixes #23398 - Don't extend classes from within initializers

Any changes to the code locally will kick in rails's auto loading which
in turn will then reload all relevant classes, and in the case of
changing a model inheriting from ApplicationRecord, then
ApplicationRecord be reloaded. So since ApplicationRecord was being
extended from within the initializer for audit then it will load the
extend however the module with still be hanging around, causing rails
throw an argument error: 'A copy of
AuditAssociations::AssociationsDefinitions has been removed from the
module tree but is still active!'.

Also note, audit_associations needs to be required because at the time
of app start up during initialization the audit_associations has not yet
been loaded. See the config/application.rb for the loading order and one
can see that models are loaded long before the audit_associations.

  • added
  • modified
  • copied
  • renamed
  • deleted