ViewComponent/view_component · error · ViewComponent::NilWithContentError

No content provided to `#with_content` for #{self}. To fix

Error message

No content provided to `#with_content` for #{self}.

To fix this issue, pass a value.

What it means

Error "No content provided to `#with_content` for #{self}. To fix this issue, pass a value." thrown in ViewComponent/view_component.

Source

Thrown at lib/view_component/with_content_helper.rb:6

# frozen_string_literal: true

module ViewComponent
  module WithContentHelper
    def with_content(value)
      raise NilWithContentError if value.nil?

      @__vc_content_set_by_with_content = value

      self
    end
  end
end

View on GitHub (pinned to 9f22c36fa7)

Solutions

  1. Pass a non-nil value to `with_content`, e.g. component.with_content('Some content').
  2. If you intended to supply content via a block, drop `with_content` and render with a block instead.

When it happens

Trigger: Thrown at lib/view_component/with_content_helper.rb:6 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/395b69a0154d2908. Report an issue: GitHub.