<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,31 +1,57 @@
 module ActionView
   module Helpers
     module ActiveRecordHelper
-      # Returns a string with a div containing all the error messages for the object located as an instance variable by the name
-      # of &lt;tt&gt;object_name&lt;/tt&gt;. This div can be tailored by the following options:
+      # Returns a string with a div containing all of the error messages for the objects located as instance variables by the names
+      # given.  If more than one object is specified, the errors for the objects are displayed in the order that the object names are
+      # provided.
+      #
+      # This div can be tailored by the following options:
       #
       # * &lt;tt&gt;header_tag&lt;/tt&gt; - Used for the header of the error div (default: h2)
       # * &lt;tt&gt;id&lt;/tt&gt; - The id of the error div (default: errorExplanation)
       # * &lt;tt&gt;class&lt;/tt&gt; - The class of the error div (default: errorExplanation)
+      # * &lt;tt&gt;object_name&lt;/tt&gt; - The object name to use in the header, or
+      # any text that you prefer. If &lt;tt&gt;object_name&lt;/tt&gt; is not set, the name of
+      # the first object will be used.
+      #
+      # Specifying one object:
+      # 
+      #   error_messages_for 'user'
+      #
+      # Specifying more than one object (and using the name 'user' in the
+      # header as the &lt;tt&gt;object_name&lt;/tt&gt; instead of 'user_common'):
+      #
+      #   error_messages_for 'user_common', 'user', :object_name =&gt; 'user'
       #
       # NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what
       # you need is significantly different from the default presentation, it makes plenty of sense to access the object.errors
       # instance yourself and set it up. View the source of this method to see how easy it is.
       #
-      # Retrofitted for Globalize by Andr&#233; Camargo
-      def error_messages_for(object_name, options = {})
-        options = options.symbolize_keys
-        object = instance_variable_get(&quot;@#{object_name}&quot;)
-        unless object.errors.empty?
-          content_tag(&quot;div&quot;,
-            content_tag(
-              options[:header_tag] || &quot;h2&quot;,
-              &quot;%d errors prohibited this #{object_name.to_s.gsub(&quot;_&quot;, &quot; &quot;).t} from being saved&quot; / object.errors.count
-            ) +
-            content_tag(&quot;p&quot;, &quot;There were problems with the following fields:&quot;.t) +
-            content_tag(&quot;ul&quot;, object.errors.full_messages.collect { |msg| content_tag(&quot;li&quot;, msg) }),
-            &quot;id&quot; =&gt; options[:id] || &quot;errorExplanation&quot;, &quot;class&quot; =&gt; options[:class] || &quot;errorExplanation&quot;
+      # Adapted for Globalize Edge Rails by Claudio Poli (claudio@icoretech.org)
+      def error_messages_for(*params)
+        options = params.last.is_a?(Hash) ? params.pop.symbolize_keys : {}
+        objects = params.collect {|object_name| instance_variable_get(&quot;@#{object_name}&quot;) }.compact
+        count   = objects.inject(0) {|sum, object| sum + object.errors.count }
+        unless count.zero?
+          html = {}
+          [:id, :class].each do |key|
+            if options.include?(key)
+              value = options[key]
+              html[key] = value unless value.blank?
+            else
+              html[key] = 'errorExplanation'
+            end
+          end
+          header_message = &quot;#{pluralize(count, 'error')} prohibited this #{(options[:object_name] || params.first).to_s.gsub('_', ' ').t} from being saved&quot;
+          error_messages = objects.map {|object| object.errors.full_messages.map {|msg| content_tag(:li, msg) } }
+          content_tag(:div,
+            content_tag(options[:header_tag] || :h2, header_message) &lt;&lt;
+              content_tag(:p, 'There were problems with the following fields:'.t) &lt;&lt;
+              content_tag(:ul, error_messages),
+            html
           )
+        else
+          ''
         end
       end
     end</diff>
      <filename>lib/globalize/rails/active_record_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c698f326c400de40fb771755889926656af89d8f</id>
    </parent>
  </parents>
  <author>
    <name>Nate Clark</name>
    <email>nate@nateclark.com</email>
  </author>
  <url>http://github.com/heythisisnate/globalize/commit/ee308406fce7f97681ec2e5813884dfa476a6c1b</url>
  <id>ee308406fce7f97681ec2e5813884dfa476a6c1b</id>
  <committed-date>2008-06-14T13:40:47-07:00</committed-date>
  <authored-date>2008-06-14T13:40:47-07:00</authored-date>
  <message>changes to active_record_helper.rb from http://codesnippets.joyent.com/posts/show/896</message>
  <tree>dd5a71109684754b1bb45252d6b966a57205c1a4</tree>
  <committer>
    <name>Nate Clark</name>
    <email>nate@nateclark.com</email>
  </committer>
</commit>
