// the find
ViewComponent/view_component
A framework for building reusable, testable & encapsulated view components in Ruby on Rails.
ViewComponent is a Rails gem for building view components as plain Ruby classes paired with a template, instead of partials and helpers. It's for Rails teams whose views have grown past the point where erb partials and helper methods stay maintainable, and who want components they can unit test without spinning up a full request.
Components are testable in isolation with a dedicated test_case/render_in API, so you can assert on markup without hitting a controller or route. The slots API handles multi-part composition (header/body/footer-style content) more cleanly than content_for conventions. Fragment caching gets real dependency tracking via cache_digest, so cache keys bust automatically when a component's template or nested components change, not just when you remember to bump a version string. The Rails version test matrix (7.1 through main/HEAD via Appraisals) shows actual compatibility testing rather than a changelog claim.
The compile/cache_digest layer is a second rendering model bolted onto Rails view resolution, and when cache invalidation misbehaves it's not obvious whether the bug is in your component or in ViewComponent's dependency tracking. Caching support is explicitly marked experimental (experimentally_cacheable.rb), so the API there can still shift under you. It only helps inside Rails view rendering — no benefit if you're doing API-only Rails or plain Ruby. Testing components means learning ViewComponent's own test helpers and system-test harness rather than reusing the controller/view test tooling your team already knows.