Inline Validation

This tutorial will show you how to implement inline server-side field validation in Rails with only a few lines of IntercoolerJS.

Video

Outline

Here are the steps for implementing inline validation

  • Extract a partial of the input div, and wrap it with a new div with an ID so we can target it for appending.
  • Create an route that will render the partial input and implement non-updating validation in the controller.
  • Add the ic-post-to annotation to the input and target the wrapping div with an ic-target annotation.

Git Diff

Here's a diff between the standard rails form code and the IntercoolerJS inline validation version:

https://github.com/LeadDyno/intercooler-tutorial-app/commit/b94118fbb5cb0ccd065c6e27d316de3e29313bce