ViewComponent/view_component · error · ViewComponent::ReservedParameterError

COMPONENT initializer can't accept the parameter `PARAMETER`

Error message

COMPONENT initializer can't accept the parameter `PARAMETER`, as it will override a public ViewComponent method. To fix this issue, rename the parameter.

What it means

Error "COMPONENT initializer can't accept the parameter `PARAMETER`, as it will override a public ViewComponent method. To fix this issue, rename the parameter." thrown in ViewComponent/view_component.

Source

Thrown at lib/view_component/base.rb:749

      # rendering is optional.
      # @private
      def __vc_validate_collection_parameter!(validate_default: false)
        parameter = validate_default ? __vc_collection_parameter : __vc_provided_collection_parameter

        return unless parameter
        return if __vc_initialize_parameter_names.include?(parameter) || __vc_splatted_keyword_argument_present?

        raise MissingCollectionArgumentError.new(name, parameter)
      end

      # Ensure the component initializer doesn't define
      # invalid parameters that could override the framework's
      # methods.
      # @private
      def __vc_validate_initialization_parameters!
        return unless __vc_initialize_parameter_names.include?(:content)

        raise ReservedParameterError.new(name, :content)
      end

      # @private
      def __vc_collection_parameter
        @__vc_provided_collection_parameter ||= name && name.demodulize.underscore.chomp("_component").to_sym
      end

      # @private
      def __vc_collection_counter_parameter
        @__vc_collection_counter_parameter ||= :"#{__vc_collection_parameter}_counter"
      end

      # @private
      def __vc_counter_argument_present?
        __vc_initialize_parameter_names.include?(__vc_collection_counter_parameter)
      end

      # @private

View on GitHub (pinned to 9f22c36fa7)

Solutions

  1. Rename the initializer parameter so it does not collide with a public ViewComponent method (e.g. `content`, `render`, `controller`, `helpers`).
  2. If the colliding name is needed internally, accept it under a different keyword argument and assign it to an instance variable.

When it happens

Trigger: Thrown at lib/view_component/base.rb:749 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/2920d5f8dd250c92. Report an issue: GitHub.