diff options
author | Tobias Lütke <tobias.luetke@gmail.com> | 2007-07-09 19:10:45 +0000 |
---|---|---|
committer | Tobias Lütke <tobias.luetke@gmail.com> | 2007-07-09 19:10:45 +0000 |
commit | 5b2be6293443a4c25aab7cf3e74fc84cb70e2199 (patch) | |
tree | dd465a436b172c779ddd0b557d1160a79489e022 /activerecord/lib/active_record | |
parent | 049b1440a392ac53a427fecd4500bb839e090be4 (diff) | |
download | rails-5b2be6293443a4c25aab7cf3e74fc84cb70e2199.tar.gz rails-5b2be6293443a4c25aab7cf3e74fc84cb70e2199.tar.bz2 rails-5b2be6293443a4c25aab7cf3e74fc84cb70e2199.zip |
Make [7169] work as expected with indented XML.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7171 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/xml_serialization.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/xml_serialization.rb b/activerecord/lib/active_record/xml_serialization.rb index 5f7a39d73b..42fe46bca3 100644 --- a/activerecord/lib/active_record/xml_serialization.rb +++ b/activerecord/lib/active_record/xml_serialization.rb @@ -207,8 +207,12 @@ module ActiveRecord #:nodoc: records = @record.send(association).to_a 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)) } + if records.empty? + builder.tag!(tag, :type => :array) + else + builder.tag!(tag, :type => :array) do + records.each { |r| r.to_xml(opts.merge(:root=>r.class.to_s.underscore)) } + end end when :has_one, :belongs_to if record = @record.send(association) |