Forum: Ruby on Rails How to supress field name in error message?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dave V. (Guest)
on 2006-04-22 15:39
(Received via mailing list)

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

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
Wilson B. (Guest)
on 2006-04-23 01:27
(Received via mailing list)
On 4/22/06, Dave V. <removed_email_address@domain.invalid> wrote:
> !=
If you don't care about the highlighting part, you can use
Otherwise, you may want to check this out:
Dave V. (Guest)
on 2006-04-23 19:40
(Received via mailing list)
Thanks Wilson

I do want to keep it specific to the fields so that they highlight,
the link mentioned in the article you referenced:

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

Anyone any ideas?
Wilson B. (Guest)
on 2006-04-24 02:39
(Received via mailing list)
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:
Dave V. (Guest)
on 2006-04-25 12:32
(Received via mailing list)
Thanks Wilson, that works.

This topic is locked and can not be replied to.