Exception: ViewComponent::ContentPassedToCachedComponentError

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

Constant Summary collapse

MESSAGE =
"COMPONENT declares `cache_on`, so it caches its own output, but its caller passed it content.\n\n" \
"Content and slots set by the caller aren't part of the cache key, so caching them would risk " \
"serving one caller's content to another.\n\n" \
"To fix this issue, either remove `cache_on` from COMPONENT, or move the content into the " \
"component and derive it from the values declared in `cache_on`.".freeze

Instance Method Summary collapse

Constructor Details

#initialize(component_name) ⇒ ContentPassedToCachedComponentError

Returns a new instance of ContentPassedToCachedComponentError.



266
267
268
# File 'lib/view_component/errors.rb', line 266

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