Skip to content

Commit ec91c69

Browse files
authored
Merge pull request #523 from github/revert-519-bmw/render-with-view-context
Revert "Always use current view context for helpers"
2 parents baed5e9 + 8f1571e commit ec91c69

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/view_component/base.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ def initialize(*); end
102102
# If trying to render a partial or template inside a component,
103103
# pass the render call to the parent view_context.
104104
def render(options = {}, args = {}, &block)
105-
view_context.render(options, args, &block)
105+
if options.is_a?(String) || (options.is_a?(Hash) && options.has_key?(:partial))
106+
view_context.render(options, args, &block)
107+
else
108+
super
109+
end
106110
end
107111

108112
def controller
@@ -113,7 +117,7 @@ def controller
113117
# Provides a proxy to access helper methods from the context of the current controller
114118
def helpers
115119
raise ViewContextCalledBeforeRenderError, "`helpers` can only be called at render time." if view_context.nil?
116-
@helpers ||= view_context
120+
@helpers ||= controller.view_context
117121
end
118122

119123
# Exposes .virutal_path as an instance method

0 commit comments

Comments
 (0)