Skip to content

Commit 966e4bf

Browse files
committed
Fixes an edge case bug where a developer may have Ruby file views in
and want to in the controller.
1 parent 80634f1 commit 966e4bf

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

lib/superview/actions.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,18 @@ def component_action_exists?(action)
9090
# If it resolves a Phlex class in the controller, it will render that. If it's
9191
# not found it continues with Rails method of resolving action names.
9292
def method_for_action(action_name)
93-
super || if component_action_exists? action_name
94-
"default_component_render"
95-
end
93+
# Yep. `super` calls this, but we have to call it here to cover the
94+
# situation where the person uas a `./app/views/users/*.rb` file with a Ruby
95+
# class in it that might be included in the controller via `include Views::Users`.
96+
# If we call super first, it will tink that `./app/views/users/show.rb` is a template
97+
# and raise an error that it doesn't have a format.
98+
if action_method?(action_name)
99+
action_name
100+
elsif component_action_exists? action_name
101+
"default_component_render"
102+
else
103+
super
104+
end
96105
end
97106

98107
# Renders a Phlex view for the given action, if it's present.

0 commit comments

Comments
 (0)