Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#969] Add support for Rails autoloader collapsed directories #970

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

bazay
Copy link

@bazay bazay commented Oct 4, 2022

Add support for collapsed autoloader directories set using Rails.autoloaders.main.collapse(...).

Checklist:

  • Add tests

Signed-off-by: Baron Bloomer <baronbloomer@gmail.com>
defined?(Rails) &&
Rails.autoloaders.main.collapse_dirs.any? &&
Rails.autoloaders.main.collapse_dirs.select { |path| path.match(model_path) }
end.map { |model_path| model_path.sub(/\/models/, '') }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern here is simply removing "/models" from the path is a hardcoded approach. To me, it could be great if we could use ActiveSupport::Inflector or Zeitwerk to define the expected path, as Zeitwerk enforces the behaviour set using Rails.autoloaders.main.collapse(...).

Signed-off-by: Baron Bloomer <baronbloomer@gmail.com>
@bazay bazay marked this pull request as draft January 10, 2023 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant