Much obliged for this answer!
On Nov 12, 3:48 pm, Fearless Fool <li...@ruby-forum.com> wrote: > I figured out the answer to my own question, and I'm embarrassed by how > trivial it is: create a helper function that takes @user, @topic, > @profile etc as an argument. For example: > > # app/helpers/my_helper.rb > module MyHelper > def my_error_message(obj) > return unless obj.errors.any? > summary = "#{pluralize(obj.errors.count, "error")} prevented this > #{obj.class} from being saved:" > msgs = obj.errors.full_messages.map { |msg| content_tag(:li, msg)}.join > > "<div > id=\"error_explanation\"><h3>#{summary}</h3><ul>#{msgs}</ul></div>".html_sa fe > end > end > > Now you can sprinkle <%= my_error_message(@user) %> in the top of > user/_form.html.erb, etc. Works like a champ. > > - ff > > -- > 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.