Blogposts uit september 2014

Rails tip: display association validation errors on fields

afbeelding van Kevin

In Ruby on Rails it is common to use a (collection) select field to set the value for a belongs_to association. However, using Rails' default form builder, validation errors on the association field are usually not correctly displayed. They are either shown on the form's label or the field, while you usually want both. In this blogpost I show a simple patch to fix this problem and make sure validation errors for associations are shown both on the label and the field itself.