Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop generating code to autoload overrides
Up to this PR, when installing Solidus, we're adding code to the host application to load files matching `app/**/*_decorator*.rb`. There exist a series of issues about that: - It goes against current recommendations on the Rails guides, where overrides are placed under `app/overrides/**/_*override.rb` ( see https://guides.rubyonrails.org/engines.html#improving-engine-functionality). - The `_decorator.rb` suffix is misleading, as that kind of overrides has to be seen as monkey patches and not related to the decorator pattern (see https://en.wikipedia.org/wiki/Decorator_pattern). - Although it's something needed a lot of times, monkey patching core classes should be seen as a last resort after ruling out other strategies (like configuring a custom class for some behavior). As such, we should not encourage it. - It may conflict with the naming used by other gems, like Draper (https://github.com/drapergem/draper). For all of that, it's something that we should address in the docs. This change is backward compatible, as the running code doesn't belong to the Solidus engine but to the previously generated applications, which will keep it after upgrading. The deleted code is, in fact, intended to work with the classic autoloader (removed on Rails 7). However, it still works because of https://github.com/rails/rails/blob/296ef7a17221e81881e38b51aa2b014d7a28bac5/activesupport/lib/active_support/dependencies/require_dependency.rb, which is deprecated. On a related information, the recommended `app/overrides/` directory is the same used by `deface` (https://github.com/spree/deface), a common dependency in Solidus projects. However, both types of overrides can coexist without interfering with each other (see solidusio#3010 (comment)). We decided to tackle the issue upstream on `deface` (see solidusio#3010 (comment)). Closes solidusio#3010
- Loading branch information