ViewComponent/view_component · error · ViewComponent::ContentAlreadySetForPolymorphicSlotError
Content for slot SLOT_NAME has already been provided.
Error message
Content for slot SLOT_NAME has already been provided.
What it means
Error "Content for slot SLOT_NAME has already been provided." thrown in ViewComponent/view_component.
Source
Thrown at lib/view_component/slotable.rb:450
end
@__vc_set_slots ||= {}
if slot_definition[:collection]
@__vc_set_slots[slot_name] ||= []
@__vc_set_slots[slot_name].push(slot)
else
@__vc_set_slots[slot_name] = slot
end
slot
end
def __vc_set_polymorphic_slot(slot_name, poly_type = nil, *args, **kwargs, &block)
slot_definition = self.class.registered_slots[slot_name]
if !slot_definition[:collection] && defined?(@__vc_set_slots) && @__vc_set_slots[slot_name]
raise ContentAlreadySetForPolymorphicSlotError.new(slot_name)
end
poly_def = slot_definition[:renderable_hash][poly_type]
__vc_set_slot(slot_name, poly_def, *args, **kwargs, &block)
end
end
end
View on GitHub (pinned to 9f22c36fa7)
Solutions
- Provide content for the slot only once: either set it via `with_SLOT(...)` or supply it in the render block, not both.
- Remove the duplicate `with_SLOT` call or the block content that fills the same slot.
When it happens
Trigger: Thrown at lib/view_component/slotable.rb:450 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ViewComponent/view_component@9f22c36fa7 (2026-08-23).
Data as JSON: /api/errors/8e4385f2ac926e32.
Report an issue: GitHub.