Skip to content

View Components

Dany Marcoux edited this page Jul 13, 2021 · 34 revisions

Using View Components... or How to Build Reusable, Testable and Encapsulated View Components in Ruby on Rails

Structure

How

  • To use helpers in components, use the helpers proxy. So if you have a helper method named user_icon, use it inside a component with helpers.user_icon.
  • Explain that all view components should inherit from ApplicationComponent because some code is shared among all view components
  • Explain policy_user methods from ApplicationComponent and why some view components need to have this instance variable in their initialize method
Clone this wiki locally