Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Clarify STI models loading process with a comment.

Pavel Balashou041ca224c373
diff --git a/config/initializers/sti_eager_load.rb b/config/initializers/sti_eager_load.rb
index ea2da38bc8d..3cdd94b830d 100644
--- a/config/initializers/sti_eager_load.rb
+++ b/config/initializers/sti_eager_load.rb
@@ -28,16 +28,21 @@
# See COPYRIGHT and LICENSE files for more details.
#++
+# Here we are loading STI models explicitly using rails autoloader.
+# It is relevant for environments where lazy loading is enabled (usually, development and testing).
+# If an STI model has not been loaded it can lead to undesired behavior like:
+# Fetching not loaded yet STI model (ServiceAccount) through its parent model(User)
+# (e.g. User.find(service_account_id) raises ActiveRecord::NotFound.
Rails.application.config.to_prepare do
- # Load Enumeration descendants due to STI
+ # Load Enumeration descendants
IssuePriority
- # Load Principal descendants due to STI
+ # Load Principal descendants
User
PlaceholderUser
Group
- # Use User descendants due to STI
+ # Load User descendants
SystemUser
AnonymousUser
Users::InexistentUser