From 8b966002fb49a4daa7da3ccb0fdc33e751d02fe9 Mon Sep 17 00:00:00 2001 From: Joel Moss Date: Thu, 12 Oct 2023 16:51:21 +0100 Subject: [PATCH] fix(ImplicitRender): Change view path as per Phlex defaults The default path to a Phlex view is `[:controller_path]/[:action_name]_view`, which is classify'ed and constantized. You can override this by defining a `phlex_view_path` method in your controller. ```ruby def phlex_view_path(action_name) "views/#{controller_path}/#{action_name}" end ``` --- lib/phlexible/rails/action_controller/implicit_render.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/phlexible/rails/action_controller/implicit_render.rb b/lib/phlexible/rails/action_controller/implicit_render.rb index 9c7a9a8..3424837 100644 --- a/lib/phlexible/rails/action_controller/implicit_render.rb +++ b/lib/phlexible/rails/action_controller/implicit_render.rb @@ -57,8 +57,14 @@ def render_plex_view(options) render assign_phlex_accessors(view.new) end + private + def phlex_view(action_name = @_action_name) - "views/#{controller_path}/#{action_name}".classify.safe_constantize + phlex_view_path(action_name).classify.constantize + end + + def phlex_view_path(action_name) + "#{controller_path}/#{action_name}_view" end end end