# How to change default error message

**URL:** <https://www.ruby-forum.com/t/how-to-change-default-error-message/153662>\
**Category:** Rails\
**Created:** [November 19, 2008, 10:11pm UTC](https://www.ruby-forum.com/t/how-to-change-default-error-message/153662 "2008-11-19T22:11:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 19, 2008, 10:11pm UTC](https://www.ruby-forum.com/t/how-to-change-default-error-message/153662/1 "2008-11-19T22:11:18Z")

</div>

Hi all,

is there a way how to change this default message “9 errors prohibited  
this user from being saved, There were problems with the following  
fields:” I’d like to be in Czech. Is it possible? Thx. P.

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 19, 2008, 10:30pm UTC](https://www.ruby-forum.com/t/how-to-change-default-error-message/153662/2 "2008-11-19T22:30:09Z")

</div>

There is a :header\_message option on error\_messages\_for:

:header\_message - The message in the header of the error div. Pass nil  
or an empty string to avoid the header message altogether. (Default:  
“X errors prohibited this object from being saved”).

[http://api.rubyonrails.org/classes/ActionView/Helpers/ActiveRecordHelper.html#M001282](http://api.rubyonrails.org/classes/ActionView/Helpers/ActiveRecordHelper.html#M001282)

You could also monkey patch ActionView::Helpers::ActiveRecordHelper if  
you want to change the default message across the entire application.

module ActionView  
module Helpers  
module ActiveRecordHelper

```
  def error_messages_for_with_message_overrides(*params)
    options = params.extract_options!.symbolize_keys
    options[:header_message] = "My Custom Error Message" unless

```

options.include?(:header\_message)  
options[:message] = “” unless options.include?  
(:message)  
error\_messages\_for\_without\_message\_overrides(params, options)  
end

```
  alias_method_chain :error_messages_for, :message_overrides
end

```

end  
end

Cheers

–  
Robert Z.  
Zapient, LLC  
Ruby on Rails Development and Consulting

[http://www.zapient.com](http://www.zapient.com)

> **[From Java To Ruby](http://www.fromjavatoruby.com)**
>
> and everything in between...

On Nov 19, 1:11 pm, Petan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
