Project

General

Profile

Bug #7934

Autoloading of Nic models does not work in some cases

Added by Marek Hulán over 4 years ago. Updated 11 months ago.

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

Description

Sometimes when we load inteface classes in wrong order it results in errors like this

/home/ares/Projekty/Zdrojaky/foreman/app/models/nic/managed.rb:2:in `<module:Nic>': uninitialized constant Nic::Interface (NameError)

The cause is that require_dependency is in base class for all children (any level of depth). So imagine we have C < B and B < A and we use B first. B requires it's parent A so before B is defined, A is defined. A also included require_dependency of C, so before B definition succeeded C had been loaded. But C requires B which file was visited but B is not defined yet which raises uninitialized constant error.

To fix this every class must require_dependency only it's direct children. This way we never jump under leave of inheritance tree that is being loaded. But going from root, we always get all children (to fix STI loading).


Related issues

Related to Foreman - Bug #8005: Another autoloading o NIC models issueClosed2014-10-21

Associated revisions

Revision 7a10a141 (diff)
Added by Marek Hulán over 4 years ago

Fixes #7934 - Set correct order of require_dependency

History

#1 Updated by The Foreman Bot over 4 years ago

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

#2 Updated by Marek Hulán over 4 years ago

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

#3 Updated by Dominic Cleal over 4 years ago

  • Legacy Backlogs Release (now unused) set to 21

#4 Updated by Marek Hulán over 4 years ago

  • Related to Bug #8005: Another autoloading o NIC models issue added

Also available in: Atom PDF