Bug #23398
Exception thrown from local dev sever on code modifications
Description
When modifying code locally then the local sever will throw the exception AuditAssociations::AssociationsDefinitions has been removed from the module tree
but is still active!'
This can be seen when editing a model that inherits from ApplicationModel and then trying to access any page in the locally running server in the browser.
Related issues
Associated revisions
History
#1
Updated by The Foreman Bot almost 5 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/5496 added
#2
Updated by Timo Goebel almost 5 years ago
- Related to Bug #23195: associations are not audited on creation added
#3
Updated by Timo Goebel almost 5 years ago
- Legacy Backlogs Release (now unused) deleted (
330)
#4
Updated by Timo Goebel almost 5 years ago
- Assignee set to Peter Lehwess
#5
Updated by Anonymous almost 5 years ago
- % Done changed from 0 to 100
- Status changed from Ready For Testing to Closed
Applied in changeset d81dc2a0c5d51e5855398d6cd2968c5afb11e440.
#6
Updated by Marek Hulán almost 5 years ago
- Legacy Backlogs Release (now unused) set to 353
#7
Updated by Ewoud Kohl van Wijngaarden over 4 years ago
- Triaged set to No
- Category set to Development tools
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.