Skip to content

Instantly share code, notes, and snippets.

@AquaGeek
Created May 14, 2011 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AquaGeek/971774 to your computer and use it in GitHub Desktop.
Save AquaGeek/971774 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #6406
diff --git a/activerecord/lib/active_record/serializers/xml_serializer.rb b/activerecord/lib/active_record/serializers/xml_serializer.rb
index 9bf1193..ae6f15a 100644
--- a/activerecord/lib/active_record/serializers/xml_serializer.rb
+++ b/activerecord/lib/active_record/serializers/xml_serializer.rb
@@ -252,7 +252,9 @@ module ActiveRecord #:nodoc:
end
else
if record = @record.send(association)
- record.to_xml(opts.merge(:root => association))
+ association_name = association.to_s.singularize
+ record_class = (record.class.to_s.underscore == association_name) ? nil : record.class.name
+ record.to_xml(opts.merge(:root => association, :type => record_class))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment