U bekijkt nu de Engelstalige versie van onze website. Klik hier om de site in het Nederlands te bekijken.

Blog posts published in September 2014

Rails tip: display association validation errors on fields

Kevin's picture

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.