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

Missing usage of view_lookup to fetch template #1057

Open
retsef opened this issue Apr 25, 2023 · 0 comments · May be fixed by #1058
Open

Missing usage of view_lookup to fetch template #1057

retsef opened this issue Apr 25, 2023 · 0 comments · May be fixed by #1058

Comments

@retsef
Copy link

retsef commented Apr 25, 2023

Currently the template for render view by controller is made by fetching directly the virtual path like controller/action

options[:template] ||= File.join(controller_path, action_name)

This can be an issue when we are in a structure where there is a couple of nesting controllers like:

  • ApplicationController
  • Admin::BaseController < ApplicationController
  • Admin::OrdersController < Admin::BaseController

With a views folder like

  • ...
  • app/views/admin/base/show.pdf.erb
  • app/views/admin/base/show.html.erb

The controller use the lookup_context to fetch the correct show view thanks to the self.local_prefixes.
Let's for example try to render the show action in html format. The lookup context try to load the first available view traversing:

  • app/views/admin/orders
  • app/views/admin/base
  • app/views/application

This should be the same as for the pdf format request but it seems not. To solve this we can directly use lookup_context

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 a pull request may close this issue.

1 participant