This project is archived and is in readonly mode.

#3543 ✓invalid

Array#to_xml doesn't pick up the root tag name like ActiveRecord#to_xml does

Reported by Pascal | December 5th, 2009 @ 10:55 PM


This is not a bug but more a orthogonality discrepancy.

Looking at the code in Array#to_xml shows that the root tag is generated with (stripped):

It should be something like this to be more consistant with ActiveRecord#to_xml:

This leverage the use of #model_name which takes care for us for those inflections.



Comments and changes to this ticket

  • David Trasbo

    David Trasbo June 12th, 2010 @ 04:27 PM

    • Assigned user set to “Ryan Bigg”

    The reason why Array#to_xml uses the generic name on the class of the first item in the array, is that the method should be able to convert any array to XML, not just an array of Active Record objects.

    That said, you could ask the first item's class if it responds to model_name, and just use name if it doesn't. Patch welcomed. For now this ticket can be marked incomplete.

  • Santiago Pastorino

    Santiago Pastorino June 18th, 2010 @ 04:01 PM

    • State changed from “new” to “invalid”

    I don't know if you're talking about Rails 2-3 or master but as David said Array#to_xml is generic so we can't use model_name

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>