hi @ all How can I modify the error messages in the view? Now, in every error message, I''ve all time the unessential lines "1 error prohibited this xxx from being saved" and "There were problems with the following fields" but I want only the real message (for example "name can''t be blank"). I need the helper error_messages_for :xxx in the views. Thanks for helping. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you want something custom you''ll probably have to create it
yourself. The error_messages_for macro just iterates through
the .errors collection on the named ActiveRecord object and introduces
it with the line that you want omitted. Something like this will
probably work:
<% unless my_object.errors.empty? %>
<ul>
<% my_object.errors.each_pair do |attr, err| %>
<% content_tag :li, "#{attr.to_s.humanize} #{errors.join('',
'')}"
<% end %>
</ul>
On Mar 9, 4:29 pm, "K. R."
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> hi @ all
> How can I modify the error messages in the view? Now, in every error
> message, I''ve all time the unessential lines "1 error
prohibited this
> xxx from being saved" and "There were problems with the following
> fields" but I want only the real message (for example "name
can''t be
> blank"). I need the helper error_messages_for :xxx in the views.
>
> Thanks for helping.
> --
> Posted viahttp://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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Great, thanks for helping... -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---