1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
Jeremy Kemper 2006-08-20 14:38:58 +00:00
parent 04d2d5f288
commit edb4208857
3 changed files with 8 additions and 1 deletions

View file

@ -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]

View file

@ -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

View file

@ -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)