# Error\_messages\_for

**URL:** <https://www.ruby-forum.com/t/error-messages-for/160974>\
**Category:** Rails\
**Created:** [February 21, 2009, 5:23pm UTC](https://www.ruby-forum.com/t/error-messages-for/160974 "2009-02-21T17:23:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [February 21, 2009, 5:23pm UTC](https://www.ruby-forum.com/t/error-messages-for/160974/1 "2009-02-21T17:23:39Z")

</div>

Is it possible to print error message near the inputbox and not all on  
top of the page by \<%= error\_messages\_for ‘users’ %\>

So if I have user registragion form and there ara inputs:

username  
password  
password\_confirm  
email

And if there some errors its prits errors near the input boxes:

username: [\_\_\_\_\_\_\_\_\_] Username should be (2 to 20 characters)  
password: [\_\_\_\_\_\_\_\_\_]  
password confirmation: [\_\_\_\_\_\_\_\_\_] Password did not match  
email [\_\_\_\_\_\_\_\_\_\_\_\_]

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [February 22, 2009, 12:41am UTC](https://www.ruby-forum.com/t/error-messages-for/160974/2 "2009-02-22T00:41:23Z")

</div>

On Feb 21, 4:23 pm, Jo Jo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is it possible to print error message near the inputbox and not all on  
> top of the page by \<%= error\_messages\_for ‘users’ %\>

Yes and no. error\_messages\_for won’t do it, but you have to realise  
that error\_messages\_for is just a way of doing errors, this nothing  
wrong with rolling your own thing (there’s very little code in  
error\_messages\_for). You might be interested in error\_message\_on which  
gets you the error messages for a single attribute.

Fred

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [February 22, 2009, 12:42pm UTC](https://www.ruby-forum.com/t/error-messages-for/160974/3 "2009-02-22T12:42:02Z")

</div>

You’ll need to use f.error\_messages and the form builder:

[http://ramblingsonrails.com/how-to-make-a-custom-form-builder-in-rails](http://ramblingsonrails.com/how-to-make-a-custom-form-builder-in-rails)

Ramon T.

On Sun, Feb 22, 2009 at 12:23 AM, Jo Jo
