Exception: ViewComponent::ReusedInstanceError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/view_component/errors.rb

Constant Summary collapse

MESSAGE =
"ViewComponent instances are single-use; a COMPONENT instance was rendered more than once.\n\n" \
"Reusing a component instance across renders can leak request-scoped state " \
"(controller, helpers, request, view_flow, slot content, `with_content`) from an earlier render " \
"into a later one, which has security and correctness implications (GHSA-8qw7-6phv-7q6p).\n\n" \
"To fix this issue, create a new component instance per render.".freeze

Instance Method Summary collapse

Constructor Details

#initialize(klass_name) ⇒ ReusedInstanceError

Returns a new instance of ReusedInstanceError.



190
191
192
# File 'lib/view_component/errors.rb', line 190

def initialize(klass_name)
  super(MESSAGE.gsub("COMPONENT", klass_name.to_s))
end