Project

General

Profile

Actions

Bug #7934

closed

Autoloading of Nic models does not work in some cases

Added by Marek Hulán over 9 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
Difficulty:
Triaged:
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 1 (0 open1 closed)

Related to Foreman - Bug #8005: Another autoloading o NIC models issueClosedTomáš Strachota10/21/2014Actions
Actions #1

Updated by The Foreman Bot over 9 years ago

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

Updated by Marek Hulán over 9 years ago

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

Updated by Dominic Cleal over 9 years ago

  • translation missing: en.field_release set to 21
Actions #4

Updated by Marek Hulán over 9 years ago

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

Also available in: Atom PDF