Well, doing some more experiments following the suggestions on commentators, to who many thanks, I tried simply moving the helper, without view_context
and helper_method
declaration out of the controller and into a helper (i.e., app/helpers/component_helper.rb
)
module ComponentHelper
def render_image_modal(**kwarg)
render(ImageModalComponent.new(**kwarg)) do |component|
yield component
end
end
end
and suddenly everything works.