# Issues Customizing ActiveRecord Error Messages

**URL:** <https://www.ruby-forum.com/t/issues-customizing-activerecord-error-messages/178468>\
**Category:** Rails\
**Created:** [November 5, 2009, 2:02am UTC](https://www.ruby-forum.com/t/issues-customizing-activerecord-error-messages/178468 "2009-11-05T02:02:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ESLitwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/5e9695/32.png) [@ESLitwin](https://www.ruby-forum.com/u/ESLitwin)\
**Post date:** [November 5, 2009, 2:02am UTC](https://www.ruby-forum.com/t/issues-customizing-activerecord-error-messages/178468/1 "2009-11-05T02:02:19Z")

</div>

I have two issues with trying to customize error messages. I’m using  
Rails 2.3.4 and Ruby 1.8.7.

The first issue has to do with basic error message interpolation.  
As an example, I modified my en.yml file and added the following:

en:  
activerecord:  
errors:  
messages:  
blank: “Please fill in your {{attribute}}”

I have a simple model with a validates\_presence\_of :name

When I submit a form without filling out name, the error message shows  
as “Name Please fill in your Name”  
What am I doing wrong that causes “Name” to show up twice?  
I feel like I am missing something basic, but looking at the Rails  
I18n API ([Rails Internationalization (I18n) API — Ruby on Rails Guides](http://guides.rubyonrails.org/i18n.html)) hasn’t helped.

The second issue has to do with validations for nested attributes.

In my en.yml, I have the following which provides a value for  
human\_name on the class. (I removed the activerecord: errors:  
messages: blank: code for this example.)

en:  
activerecord:  
models:  
adhoc\_filter: “Filter”

In my adhoc\_filter child model, I have a validates\_presence\_of :field

When I submit the form, the error message shows up as “Adhoc filters  
field can’t be blank” instead of “Filter field can’t be blank”

I’m not sure if nested attribute errors will work the way I want them  
to, but it would be nice.

Any advice on one or both of these issues is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![ESLitwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/5e9695/32.png) [@ESLitwin](https://www.ruby-forum.com/u/ESLitwin)\
**Post date:** [November 6, 2009, 5:41pm UTC](https://www.ruby-forum.com/t/issues-customizing-activerecord-error-messages/178468/2 "2009-11-06T17:41:11Z")

</div>

As a follow up to the second issue, if I specify the error message as:

en:  
activerecord:  
errors:  
messages:  
blank: “-- {{attribute}} - {{model}}”

I see the following error: “Adhoc filters fields – Adhoc filters  
field – Filter”

So the model human name is getting set correctly, but the child  
attribute is getting concatenated with the non human-name of the model  
with the child field.
