aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-08-20 14:38:58 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-08-20 14:38:58 +0000
commitedb42088571f9ad61908032c3df12b4700e099e9 (patch)
treef806b2d7dd3d2b855ed81698b9bad69ceefd0d78 /activerecord
parent04d2d5f2884677542b7062ece98bd91978e78b2b (diff)
downloadrails-edb42088571f9ad61908032c3df12b4700e099e9.tar.gz
rails-edb42088571f9ad61908032c3df12b4700e099e9.tar.bz2
rails-edb42088571f9ad61908032c3df12b4700e099e9.zip
to_xml: correct naming of included associations. Closes #5831.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4794 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/xml_serialization.rb2
-rwxr-xr-xactiverecord/test/base_test.rb5
3 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 2a9a7c2042..4d117fd79b 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* to_xml: correct naming of included associations. #5831 [josh.starcher@gmail.com]
+
* Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [josh@hasmanythrough.com]
* PostgreSQL: simplify index introspection query. #5819 [stephen_purcell@yahoo.com]
diff --git a/activerecord/lib/active_record/xml_serialization.rb b/activerecord/lib/active_record/xml_serialization.rb
index 5324ae5a0a..2e4a038886 100644
--- a/activerecord/lib/active_record/xml_serialization.rb
+++ b/activerecord/lib/active_record/xml_serialization.rb
@@ -190,7 +190,7 @@ module ActiveRecord #:nodoc:
tag = tag.dasherize if dasherize?
builder.tag!(tag) do
- records.each { |r| r.to_xml(opts) }
+ records.each { |r| r.to_xml(opts.merge(:root => association.to_s.singularize)) }
end
end
when :has_one, :belongs_to
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index f52253dd8b..8fe57c35b9 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -1319,6 +1319,11 @@ class BasicsTest < Test::Unit::TestCase
assert xml.include?(%(<replies><reply>))
assert xml.include?(%(<title>The Second Topic's of the day</title>))
end
+
+ def test_array_to_xml_including_has_many_association
+ xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :include => :replies)
+ assert xml.include?(%(<replies><reply>))
+ end
def test_array_to_xml_including_has_one_association
xml = [ companies(:first_firm), companies(:rails_core) ].to_xml(:indent => 0, :skip_instruct => true, :include => :account)