Highlighting Select2 Fields with Rails Validation

Select2 is a great way to add customizable select boxes with support for searching, tagging, remote data sets, infinite scrolling, and much more to your Rails application.

While setting up select2 is beyond the scope of this post, one useful Rails ability that you lose when using select2 fields inside of a Rails form helper is the automatic highlighting of fields that fail your rails model validations.

Highlighting Errors


In the above image you can see that rails was properly