Project

General

Profile

Actions

Bug #7934

closed

Autoloading of Nic models does not work in some cases

Added by Marek Hulán about 10 years ago. Updated over 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

Also available in: Atom PDF