Project

General

Profile

Actions

Defect #30753

closed

Plugins auto_load and eager_load paths

Added by Florian Schwab about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Plugin API
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

This is actually a follow-up patch to #30725 (as I was digging deeper into this topic).

If a plugin uses e.g. ActiveJob, ActionCable etc. or puts the mailer classes into app/mailers (Rails default) instead of app/models the current implementation only adds the fixed subdirectories controllers, helpers, models of the app directory to the auto load paths and eager load paths.
The contents of Rails.application.config.eager_load_paths will only be eager loaded if eager load is enabled, so adding the plugin directories can be done always not only if eager load is enabled.

Rails defines and detects paths that should be included in auto loading or eager loading through an abstraction:
https://github.com/rails/rails/blob/v5.2.2/railties/lib/rails/engine/configuration.rb#L37

The attached patched uses this to load all pathes you would expect from normal Rails app with the same behaviour.
This might not be 100% complete but definitely better than it is now.
I guess the assets stuff should also be handled accordingly but currently I'm not quite sure how... if I will ever find out, I'll let you know ;-)


Files


Related issues

Related to Redmine - Patch #30725: Plugin eager_load should depend on environment setting instead of nameClosedGo MAEDA

Actions
Related to Redmine - Feature #23630: Migrate to Rails 5.2ClosedJean-Philippe Lang

Actions
Actions

Also available in: Atom PDF