AstraForm

Description

AstraForm is Wunder’s form object pattern. It allows encapsulating complex form logic into an object and out of the view. It has these advantages:

  • accepts_nested_attributes works for basic cases, but if you’re saving multiple models with complex logic, AstraForm may help.
  • When you have complex form validations, but you don’t want them to run in contexts outside of the form, they can be placed on the AstraForm model.
  • AstraForms can be easily unit tested, which is often easier than integration or controller tests.
  • AstraForms will automatically sanitize params, which can clean up unwieldy lists of params in the controller.

Most forms won’t need to be an AstraForm. We default to standard Rails forms.

Technology Status at Wunder

Adopt. When you find a form getting very complex, this is a tool you can use to encapsulate that complexity.