About rails error_messages


#1

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

http://media.pragprog.com/titles/rails2/code/depot_p/app/views/store/checkout.rhtml


#2

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

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

http://media.pragprog.com/titles/rails2/code/depot_p/app/views/store/checkout.rhtml