The current to_xml behavior is incorrect. It singularizes
already singular association names, resulting in xml that does not
represent the original models/associations. Attached patch fixes
this.
Steps to reproduce
Say we have the following models:
class Address < ActiveRecord::Base; belongs_to :person; end
class Person < ActiveRecord::Base; has_one :address; end
Now, in Rails console, find a Person and do:
> @person.to_xml(:skip_instruct => true, :include => :address)
Current to_xml result (Rails 3.0.4):
<person>
<id type="integer">1</id>
<addres>
<id type="integer">1</id>
</addres>
</person>
After applying patch:
<person>
<id type="integer">1</id>
<address>
<id type="integer">1</id>
</address>
</person>
(notice the difference in the spelling of 'address')