# Error message

**URL:** <https://www.ruby-forum.com/t/error-message/131424>\
**Category:** Rails\
**Created:** [March 9, 2008, 9:29pm UTC](https://www.ruby-forum.com/t/error-message/131424 "2008-03-09T21:29:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [March 9, 2008, 9:29pm UTC](https://www.ruby-forum.com/t/error-message/131424/1 "2008-03-09T21:29:09Z")

</div>

hi @ all  
How can I modify the error messages in the view? Now, in every error  
message, I’ve all time the unessential lines “1 error prohibited this  
xxx from being saved” and “There were problems with the following  
fields” but I want only the real message (for example “name can’t be  
blank”). I need the helper error\_messages\_for :xxx in the views.

Thanks for helping.

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [March 10, 2008, 1:14pm UTC](https://www.ruby-forum.com/t/error-message/131424/2 "2008-03-10T13:14:08Z")

</div>

If you want something custom you’ll probably have to create it  
yourself. The error\_messages\_for macro just iterates through  
the .errors collection on the named ActiveRecord object and introduces  
it with the line that you want omitted. Something like this will  
probably work:

\<% unless my\_object.errors.empty? %\>

\<% my\_object.errors.each\_pair do |attr, err| %\> \<% content\_tag :li, "#{attr.to\_s.humanize} #{errors.join(', ')}" \<% end %\>

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [March 10, 2008, 2:54pm UTC](https://www.ruby-forum.com/t/error-message/131424/3 "2008-03-10T14:54:02Z")

</div>

Great, thanks for helping…
