Back to the guide

Pre-built components shipped with Compony

Compony comes with a few pre-built components that cover the most common cases that can be speed up development. They are meant to be inherited from and the easiest way to do this is by using the provided Rails generators rails g component ....

The pre-built components can be found in the module Compony::Components. They ship a sensible, UI-agnostic default (plain HTML, no styling) — you typically inherit from them in an app base layer that adds your UI framework's markup (see Real-world patterns). Show and Index are intentionally minimal because their presentation depends heavily on your UI framework; they are easy to override (see the example).

In the following, the pre-built components currently shipped with Compony are presented:

  • Show: Compony's equivalent to Rail's show controller action
  • Index: Compony's equivalent to Rail's index controller action
  • List: Compony's equivalent to Rail's _list partial
  • Destroy: Compony's equivalent to Rail's destroy controller action
  • WithForm: A base class for components containing and submitting forms
  • Form: Compony's equivalent to Rail's _form partial
  • New: Compony's equivalent to Rail's new and create controller action
  • Edit: Compony's equivalent to Rail's edit and update controller action

Guide index