Posted about 5 years ago. Visible to the public.

Always show all form errors during development

You've been there: A form cannot be submitted, but you don't see a validation error because the field at fault has no corresponding input field on the form. Because this is usually a bug, you insert debug information listing all errors into the form view. And once the bug is fixed, you forget to take out that debug information.

There is a better way. By copying the attached initializer into config/initializers, your form_for forms will always render a small box listing all form errors in the bottom right corner of the screen. This box is never shown in environments other than development.

Rails-XSS is required by default. So if your project doesn't support Rails-XSS just remove all .html_safe calls.


Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Author of this card:

Henning Koch
Last edit:
over 1 year ago
by Dominik Schöler
example.png, form_for_with_development_errors.rb
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandropedia