Link Search Menu Expand Document


ViewComponent is supported natively in Rails 6.1, and compatible with Rails 5.0+ via an included monkey patch.

ViewComponent is tested for compatibility with combinations of Ruby v2.5+ and Rails v5+. Ruby 2.4 is likely compatible, but is no longer tested.

Disabling the render monkey patch (Rails < 6.1)

In order to avoid conflicts between ViewComponent and other gems that also monkey patch the render method, it is possible to configure ViewComponent to not include the render monkey patch:

config.view_component.render_monkey_patch_enabled = false # defaults to true

With the monkey patch disabled, use render_component (or render_component_to_string) instead:

<%= render_component "bar") %>

Bridgetown (Static Site Generator)

Bridgetown supports ViewComponent via an experimental shim provided by the bridgetown-view-component gem. More information available here.


Using rich_text_area from ActionText in a ViewComponent will result in this error:

undefined method 'rich_text_area_tag'

This is due to ViewComponent not having access to the helpers it needs via ActionText. As a workaround, add the following to your component (or base component):

delegate :rich_text_area_tag, to: :helpers