diff options
author | Tobias Lütke <tobias.luetke@gmail.com> | 2007-07-09 18:13:24 +0000 |
---|---|---|
committer | Tobias Lütke <tobias.luetke@gmail.com> | 2007-07-09 18:13:24 +0000 |
commit | 049b1440a392ac53a427fecd4500bb839e090be4 (patch) | |
tree | 9ae9c891f70dd7d6a6b1390a0abd3cc9ca21c396 /activerecord/lib/active_record | |
parent | 124161569273e050d9e0389717cf36a491c6c119 (diff) | |
download | rails-049b1440a392ac53a427fecd4500bb839e090be4.tar.gz rails-049b1440a392ac53a427fecd4500bb839e090be4.tar.bz2 rails-049b1440a392ac53a427fecd4500bb839e090be4.zip |
Include empty has_many/has_and_belongs_to_many associations as empty array tags when serializing to XML
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7169 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/xml_serialization.rb | 11 |
1 files changed, 4 insertions, 7 deletions
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) |