{"record":{"id":"1978421e1b81fa07","repo":"ViewComponent/view_component","slug":"the-initializer-for-component-doesn-t-accept-the-p","errorCode":null,"errorMessage":"The initializer for COMPONENT doesn't accept the parameter `PARAMETER`, which is required to render it as a collection.\n\nTo fix this issue, update the initializer to accept `PARAMETER`.\n\nSee [the collections docs](https://viewcomponent.org/guide/collections.html) for more information on rendering collections.","messagePattern":"The initializer for COMPONENT doesn't accept the parameter `PARAMETER`, which is required to render it as a collection\\.\n\nTo fix this issue, update the initializer to accept `PARAMETER`\\.\n\nSee \\[the collections docs\\]\\(https://viewcomponent\\.org/guide/collections\\.html\\) for more information on rendering collections\\.","errorType":"exception","errorClass":"ViewComponent::MissingCollectionArgumentError","httpStatus":null,"severity":"error","filePath":"lib/view_component/base.rb","lineNumber":739,"sourceCode":"      #\n      # @return [Boolean]\n      def strip_trailing_whitespace?\n        __vc_strip_trailing_whitespace\n      end\n\n      # Ensure the component initializer accepts the\n      # collection parameter. By default, we don't\n      # validate that the default parameter name\n      # is accepted, as support for collection\n      # rendering is optional.\n      # @private\n      def __vc_validate_collection_parameter!(validate_default: false)\n        parameter = validate_default ? __vc_collection_parameter : __vc_provided_collection_parameter\n\n        return unless parameter\n        return if __vc_initialize_parameter_names.include?(parameter) || __vc_splatted_keyword_argument_present?\n\n        raise MissingCollectionArgumentError.new(name, parameter)\n      end\n\n      # Ensure the component initializer doesn't define\n      # invalid parameters that could override the framework's\n      # methods.\n      # @private\n      def __vc_validate_initialization_parameters!\n        return unless __vc_initialize_parameter_names.include?(:content)\n\n        raise ReservedParameterError.new(name, :content)\n      end\n\n      # @private\n      def __vc_collection_parameter\n        @__vc_provided_collection_parameter ||= name && name.demodulize.underscore.chomp(\"_component\").to_sym\n      end\n\n      # @private","sourceCodeStart":721,"sourceCodeEnd":757,"githubUrl":"https://github.com/ViewComponent/view_component/blob/9f22c36fa7d7b44098a8ed97472e3b4674ae420f/lib/view_component/base.rb#L721-L757","documentation":"Error \"The initializer for COMPONENT doesn't accept the parameter `PARAMETER`, which is required to render it as a collection.\n\nTo fix this issue, update the initializer to accept `PARAMETER`.\n\nSee [the collections docs](https://viewcomponent.org/guide/collections.html) for more information on rendering collections.\" thrown in ViewComponent/view_component.","triggerScenarios":"Thrown at lib/view_component/base.rb:739 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the missing parameter to the component's initializer, e.g. def initialize(parameter:) - the parameter name is the singular name derived from the collection variable.","If the collection item should use a different name, set `with_collection_parameter :custom_name` in the component and use that name in the initializer."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9f22c36fa7d7b44098a8ed97472e3b4674ae420f","analyzedAt":"2026-08-23T10:20:47.008Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}