Yeah, sorry, I meant the model attribute and meant model.

I'm not sure how you would arrange the error messages in a specific 
order like that, but you can place them alongside each field.

http://guides.rails.info/activerecord_validations_callbacks.html#customizing-the-error-messages-html

For example, in my app I use:

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
  if html_tag =~ /label for/
    if instance.error_message.kind_of?(Array)
      %(<span class="validation-error">#{html_tag} 
#{instance.error_message.join(', and ')}.</span>)
    else
      %(<span class="validation-error">#{html_tag} 
#{instance.error_message}.</span>)
    end
  else
  %(#{html_tag})
  end
end

(I realize that code isn't very neat - I wrote it a few months ago and 
it's worked fine, so I haven't touched it since.)

And then my forms look like:

<p>
  <b><%= f.label :name %></b><br />
  <%= f.text_field :name, :size => 50 %>
</p>
<p>
  <b><%= f.label :email %></b><br />
  <%= f.text_field :email, :size => 50 %>
</p>
<p>
  <b><%= f.label :password %></b><br />
  <%= f.password_field :password, :size => 50 %>
</p>

And in my CSS file: span.validation-error{color:red}

So, whenever the form is submitted and has errors, the labels are 
replaced with the error messages in red.

So this:
Email
(email text field)

becomes

Email is too short, and does not look valid
(email text field)

Anyway, that's my solution, and I think it looks nice, but of course 
feel free to be creative.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to