I wanted to change the default message that Rails’ FormBuilder provides. “X errors prohibited this Y from being created” is just a little stiff. I dig something a little more conversational; something like “Oh uh…”. Being a programmer, I’m lazy. I don’t want to set this on every form in my app. This calls for a monkey patch. Add the below code into a file, say something like config/initializers/form_builder.rb:
module ActionView
module Helpers
class FormBuilder
def errors
if error_messages.present?
error_messages(:message => "", :header_message => "Oh uh… Something's up.")
end
end
end
end
end
To use this new method just add it into your form like so:
- form_for(@page) do |f|
= f.errors
= f.text_field :page
= f.submit "Create Page"
== -or-
= link_to "Cancel", pages_path
This gives us something a little more friendly:
Oh uh… Something’s up.
- Title can’t be blank






