I would like to know if there is a way (a plugin?) to display all message errors for a given object in rails 3. For example, here my validations:
validates_presence_of :email, :message => "Your Email can't be blank"
validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
which will be displayed in the view like this:
Your Email can't be blank
Email is invalid
If I use error_message_on (@user, :email) I’ll get the first message error, So
my start has to create a loop and extract the related method (example the @user.email) Is it the right way?
EDIT
This almost achieves it:
<ul>
<%= @user.errors.on(:email).each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
But it returns also the array, How can I manage this?
Your Email can't be blank
is invalid
["Your Email can't be blank", "is invalid"]
Thank you!
and as an helper: