Project

General

Profile

Bug #23398

Exception thrown from local dev sever on code modifications

Added by Peter Lehwess 5 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Development tools
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

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

Related to Foreman - Bug #23195: associations are not audited on creationClosed2018-04-10

Associated revisions

Revision d81dc2a0 (diff)
Added by Peter Lehwess 5 months 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.

History

#1 Updated by The Foreman Bot 5 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5496 added

#2 Updated by Timo Goebel 5 months ago

  • Related to Bug #23195: associations are not audited on creation added

#3 Updated by Timo Goebel 5 months ago

  • Legacy Backlogs Release (now unused) deleted (330)

#4 Updated by Timo Goebel 5 months ago

  • Assignee set to Peter Lehwess

#5 Updated by Anonymous 5 months ago

  • % Done changed from 0 to 100
  • Status changed from Ready For Testing to Closed

#6 Updated by Marek Hulán 5 months ago

  • Legacy Backlogs Release (now unused) set to 353

#7 Updated by Ewoud Kohl van Wijngaarden 2 months ago

  • Triaged set to No
  • Category set to Development tools

Also available in: Atom PDF