{"record":{"id":"a012a6fabc2951f7","repo":"ViewComponent/view_component","slug":"component-declares-a-slot-named-content-which-is","errorCode":null,"errorMessage":"COMPONENT declares a slot named content, which is a reserved word in ViewComponent.\n\nContent passed to a ViewComponent as a block is captured and assigned to the `content` accessor without having to create an explicit slot.\n\nTo fix this issue, either use the `content` accessor directly or choose a different slot name.","messagePattern":"COMPONENT declares a slot named content, which is a reserved word in ViewComponent\\.\n\nContent passed to a ViewComponent as a block is captured and assigned to the `content` accessor without having to create an explicit slot\\.\n\nTo fix this issue, either use the `content` accessor directly or choose a different slot name\\.","errorType":"exception","errorClass":"ViewComponent::ContentSlotNameError","httpStatus":null,"severity":"error","filePath":"lib/view_component/slotable.rb","lineNumber":319,"sourceCode":"        end\n\n        slot\n      end\n\n      def __vc_validate_plural_slot_name(slot_name)\n        if RESERVED_NAMES[:plural].include?(slot_name.to_sym)\n          raise ReservedPluralSlotNameError.new(name, slot_name)\n        end\n\n        __vc_raise_if_slot_name_uncountable(slot_name)\n        __vc_raise_if_slot_conflicts_with_call(slot_name)\n        __vc_raise_if_slot_ends_with_question_mark(slot_name)\n        __vc_raise_if_slot_registered(slot_name)\n      end\n\n      def __vc_validate_singular_slot_name(slot_name)\n        if slot_name.to_sym == :content\n          raise ContentSlotNameError.new(name)\n        end\n\n        if RESERVED_NAMES[:singular].include?(slot_name.to_sym)\n          raise ReservedSingularSlotNameError.new(name, slot_name)\n        end\n\n        __vc_raise_if_slot_conflicts_with_call(slot_name)\n        __vc_raise_if_slot_ends_with_question_mark(slot_name)\n        __vc_raise_if_slot_registered(slot_name)\n      end\n\n      def __vc_raise_if_slot_registered(slot_name)\n        if registered_slots.key?(slot_name)\n          raise RedefinedSlotError.new(name, slot_name)\n        end\n      end\n\n      def __vc_raise_if_slot_ends_with_question_mark(slot_name)","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/ViewComponent/view_component/blob/9f22c36fa7d7b44098a8ed97472e3b4674ae420f/lib/view_component/slotable.rb#L301-L337","documentation":"Raised when a singular slot name is exactly :content (lib/view_component/slotable.rb:318-320). ViewComponent captures any block passed at the call site into the built-in content accessor, so a slot named content would collide with that accessor and make the intent ambiguous. The error tells the developer to use the content accessor directly or to pick another name.","triggerScenarios":"renders_one :content, and renders_many :content, whose singularized form is also :content and is validated at lib/view_component/slotable.rb:151. renders_many :contents instead hits the plural reserved list first and raises ReservedPluralSlotNameError.","commonSituations":"An optional rich text area named content; components migrated from partials that had a content local; developers combining a content slot with the with_content helper, which is exactly the overlap the framework prevents.","solutions":["Rename the slot to describe what it holds, for example :body, :summary or :description","Drop the slot and rely on the built-in content accessor: pass a block at the call site and read content in the template","Use content.present? in the template when the component needs optional content with a fallback"],"exampleFix":"# before\nclass PanelComponent < ViewComponent::Base\n  renders_one :content # raises ContentSlotNameError\nend\n\n# after\nclass PanelComponent < ViewComponent::Base\n  renders_one :body\nend\n# template reads body, or the built-in content accessor","handlingStrategy":"validation","validationCode":"def slot_name_available?(name)\n  name.to_sym != :content\nend\n\nslot_name_available?(:content) # => false","typeGuard":null,"tryCatchPattern":"# config-driven registration only\nbegin\n  renders_one(dynamic_name.to_sym)\nrescue ViewComponent::ContentSlotNameError\n  dynamic_name = :body\n  retry\nend","preventionTips":["Treat content as taken: block content already arrives through the content accessor","Prefer concrete names such as :body or :summary for optional content areas","Remember that renders_many :content also fails here because its singular form is content"],"tags":["ruby","rails","view-component","slots","reserved-words","content"],"backgroundTag":"reserved-name-conflict","analyzedSha":"9f22c36fa7d7b44098a8ed97472e3b4674ae420f","analyzedAt":"2026-08-23T10:20:47.008Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}