# About rails error\_messages

**URL:** <https://www.ruby-forum.com/t/about-rails-error-messages/161994>\
**Category:** Rails\
**Created:** [March 4, 2009, 5:00pm UTC](https://www.ruby-forum.com/t/about-rails-error-messages/161994 "2009-03-04T17:00:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![difei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@difei](https://www.ruby-forum.com/u/difei)\
**Post date:** [March 4, 2009, 5:00pm UTC](https://www.ruby-forum.com/t/about-rails-error-messages/161994/1 "2009-03-04T17:00:11Z")

</div>

Hi all,

I have a web form:

\<% form\_for @comment do |f| %\>  
\<%= f.error\_messages %\>

\<%= f.label :author %\> \<%= f.text\_field :author, :size =\> 20 %\> %\>

\<%= f.label :email %\> \<%= f.text\_field :email, :size =\> 20 %\>

\<% end %\>

When the validation fails, the labels will be wrapped into

, so  
labels and fields are in different lines, that is not what I want. If  
you have the agile web development book, please turn to p.151 (the  
source code is in p.146 and [1]), how did the author archived that?  
Thanks.

Difei

1. 

[http://media.pragprog.com/titles/rails2/code/depot\_p/app/views/store/checkout.rhtml](http://media.pragprog.com/titles/rails2/code/depot_p/app/views/store/checkout.rhtml)

---

<div class="post-metadata">

**Author:** ![difei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@difei](https://www.ruby-forum.com/u/difei)\
**Post date:** [March 4, 2009, 8:57pm UTC](https://www.ruby-forum.com/t/about-rails-error-messages/161994/2 "2009-03-04T20:57:14Z")

</div>

There’s lots of good info about how to customize the error message  
output here:

[http://apidock.com/rails/ActionView/Helpers/ActiveRecordHelper/error\_messages\_for](http://apidock.com/rails/ActionView/Helpers/ActiveRecordHelper/error_messages_for)

Difei Z. wrote:

> Hi all,
> 
> I have a web form:
> 
> \<% form\_for @comment do |f| %\>  
> \<%= f.error\_messages %\>
> 
> \<%= f.label :author %\> \<%= f.text\_field :author, :size =\> 20 %\> %\>
> 
> \<%= f.label :email %\> \<%= f.text\_field :email, :size =\> 20 %\>
> 
> \<% end %\>
> 
> When the validation fails, the labels will be wrapped into
> 
> , so  
> labels and fields are in different lines, that is not what I want. If  
> you have the agile web development book, please turn to p.151 (the  
> source code is in p.146 and [1]), how did the author archived that?  
> Thanks.
> 
> Difei
> 
> 1. 
> 
> [http://media.pragprog.com/titles/rails2/code/depot\_p/app/views/store/checkout.rhtml](http://media.pragprog.com/titles/rails2/code/depot_p/app/views/store/checkout.rhtml)
