Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Action View: Fallback to existing partial when possible
Closes [rails#50844][] Motivation / Background --- A controller declared in the top-level module can render a top-level Active Model instance whose partial is declared in the root view directory (like `articles/_article.html.erb`). A controller scoped within a module can render an Active Model instance whose partial is similarly scoped within view directory (like `scoped/articles/_article.html.erb`). A controller scoped within a module cannot render an Active Model instance whose partial is declared in the root view directory (like `articles/_article.html.erb`), despite the absence of a similarly scoped partial. This is intended behavior that's powered by [`config.action_view.prefix_partial_path_with_controller_namespace = true`][prefix_partial_path_with_controller_namespace] (`true` by default). This change was introduced in March of 2012 as part of [rails#5625][]. Detail --- As a consumer of Action View, my intuition is that the lookup would fallback, in the same way that a controller that inherits from `ApplicationController` could define its own view, then rely on fallback to render an `app/views/application` partial. This commit modifies the behavior to gracefully fall back to the root-level view partial. Checklist --- Before submitting the PR make sure the following are checked: * [x] This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs. * [x] Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: `[Fix #issue-number]` * [x] Tests are added or updated if you fix a bug or add a feature. * [x] CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included. [#59844]: rails#50844 [prefix_partial_path_with_controller_namespace]: https://guides.rubyonrails.org/configuring.html#config-action-view-prefix-partial-path-with-controller-namespace [rails#5625]: rails#5625
- Loading branch information