3 Commits

Author SHA1 Message Date
Pavel Balashou 041ca224c3 Clarify STI models loading process with a comment. 2025-07-07 11:01:32 +02:00
Pavel Balashou b78678c5ec Load STI models explicitly.
Due to STI nature it is required. Otherwise undesired behavior is possible
in dev and test environments(where usually lazy loading is enabled).
The udesired behavior can be like:
  Fetching not loaded yet STI model through its parent model
  (e.g. `User.find(service_account_id)` raises `ActiveRecord::NotFound`, because
  `ServiceAccount` has not been referenced yet.

`SubclassRegistry` has been removed, because:
1. `.register_subclasses` and `.registered_subclasses` produce unexpected results.
    ```ruby
      # e.g.: Principal -> User -> ServiceAccount
      Principal.register_subclass(User)

      # Then
      Principal.registered_subclasses == [User] # true
      User.registered_subclasses == [User] # true
      ServiceAccount.registered_subclasses == [User] # true
      # Having User as a subclass of User and ServiceAccount seems to be weird.
    ```

2. There seems to be no big win in have the additional list of subclasses that have to be manually filled.
3. Used in commit apprach seems to be simpler.
   It is just calling STI classes explicitly in to_prepare block of configuration.
2025-06-20 17:00:08 +02:00
Oliver Günther d0ef27dcb6 Introduce registry to ensure we eager load all of them 2024-08-22 14:41:23 +02:00