diff --git a/activerecord/lib/active_record/xml_serialization.rb b/activerecord/lib/active_record/xml_serialization.rb index 88ff46a004..5f7a39d73b 100644 --- a/activerecord/lib/active_record/xml_serialization.rb +++ b/activerecord/lib/active_record/xml_serialization.rb @@ -205,13 +205,10 @@ module ActiveRecord #:nodoc: case @record.class.reflect_on_association(association).macro when :has_many, :has_and_belongs_to_many records = @record.send(association).to_a - unless records.empty? - tag = association.to_s - tag = tag.dasherize if dasherize? - - builder.tag!(tag, :type => :array) do - records.each { |r| r.to_xml(opts.merge(:root=>r.class.to_s.underscore)) } - end + tag = association.to_s + tag = tag.dasherize if dasherize? + builder.tag!(tag, :type => :array) do + records.each { |r| r.to_xml(opts.merge(:root=>r.class.to_s.underscore)) } end when :has_one, :belongs_to if record = @record.send(association) diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/xml_serialization_test.rb index 8c59d5d26b..824f486d2e 100644 --- a/activerecord/test/xml_serialization_test.rb +++ b/activerecord/test/xml_serialization_test.rb @@ -162,4 +162,12 @@ class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase assert_match %r{^ }, xml assert_no_match %r{^