# How to supress field name in error message?

**URL:** <https://www.ruby-forum.com/t/how-to-supress-field-name-in-error-message/58514>\
**Category:** Rails\
**Created:** [April 22, 2006, 1:39pm UTC](https://www.ruby-forum.com/t/how-to-supress-field-name-in-error-message/58514 "2006-04-22T13:39:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveverwer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@daveverwer](https://www.ruby-forum.com/u/daveverwer)\
**Post date:** [April 22, 2006, 1:39pm UTC](https://www.ruby-forum.com/t/how-to-supress-field-name-in-error-message/58514/1 "2006-04-22T13:39:54Z")

</div>

Hi

How do I supress the reporting of a field name in the full error  
message? I want the error to be associated with the field so that the  
.fieldWithErrors class is applied to the field but I don’t want it to  
add the field name to the actual error message.

For example:

errors.add(“occurs\_on”, “The date can’t be today!”) unless occurs\_on  
!= Date.today

I would like the error to read:

The date can’t be today!

Rather than:

Occurs on The date can’t be today!

Is there any way to do this?

Thanks in advance  
Dave

---

<div class="post-metadata">

**Author:** ![daveverwer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@daveverwer](https://www.ruby-forum.com/u/daveverwer)\
**Post date:** [April 22, 2006, 11:27pm UTC](https://www.ruby-forum.com/t/how-to-supress-field-name-in-error-message/58514/2 "2006-04-22T23:27:55Z")

</div>

On 4/22/06, Dave V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> != Date.today

If you don’t care about the highlighting part, you can use  
errors.add\_to\_base.  
Otherwise, you may want to check this out:  
[http://www.railtie.net/articles/2006/01/26/enhancing\_rails\_errors](http://www.railtie.net/articles/2006/01/26/enhancing_rails_errors)

---

<div class="post-metadata">

**Author:** ![daveverwer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@daveverwer](https://www.ruby-forum.com/u/daveverwer)\
**Post date:** [April 23, 2006, 5:40pm UTC](https://www.ruby-forum.com/t/how-to-supress-field-name-in-error-message/58514/3 "2006-04-23T17:40:18Z")

</div>

Thanks Wilson

I do want to keep it specific to the fields so that they highlight,  
the link mentioned in the article you referenced:  
[Peak Obsession](http://wiki.rubyonrails.com/rails/pages/Custom+Error+Message)

This seems like about the solution I was looking for, however I am not  
sure how to install it? It comes with an init.rb file and a lib folder  
with one rb file in it. I have put the init.rb in my project root and  
the other file into my lib folder but it doesnt seem to override the  
class.

Anyone any ideas?

---

<div class="post-metadata">

**Author:** ![daveverwer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@daveverwer](https://www.ruby-forum.com/u/daveverwer)\
**Post date:** [April 24, 2006, 12:39am UTC](https://www.ruby-forum.com/t/how-to-supress-field-name-in-error-message/58514/4 "2006-04-24T00:39:02Z")

</div>

That’s a Rails ‘plugin’, so you need to extract it into the  
vendor/plugins/ folder under your Rails project root.  
There are some brief instructions at the bottom of the page:  
[http://www.railtie.net/articles/2006/01/26/enhancing\_rails\_errors](http://www.railtie.net/articles/2006/01/26/enhancing_rails_errors)

---

<div class="post-metadata">

**Author:** ![daveverwer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@daveverwer](https://www.ruby-forum.com/u/daveverwer)\
**Post date:** [April 25, 2006, 10:32am UTC](https://www.ruby-forum.com/t/how-to-supress-field-name-in-error-message/58514/5 "2006-04-25T10:32:30Z")

</div>

Thanks Wilson, that works.

Dave
