Bug #7934
closedAutoloading of Nic models does not work in some cases
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).
Updated by The Foreman Bot about 10 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/1853 added
- Pull request deleted (
)
Updated by Marek Hulán about 10 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 7a10a1419fcdeb082c80434ceb56f5294851eb23.
Updated by Dominic Cleal about 10 years ago
- Translation missing: en.field_release set to 21
Updated by Marek Hulán about 10 years ago
- Related to Bug #8005: Another autoloading o NIC models issue added