This project is archived and is in readonly mode.

#2769 ✓stale

ActiveSupport::CoreExtensions::Array::Conversions#to_xml modifies the passed option hash

Reported by ThePhred | June 5th, 2009 @ 09:03 PM | in 3.x

test = {}
[].to_xml( test )

Now test is equal to the following instead of {}:

{:indent=>2, :builder=><?xml version="1.0" encoding="UTF-8"?>
<nil-classes type="array"/>

The situation that makes this bad is:

class SomeController < ApplicationController
  TO_XML_OPTIONS_HASH = { :indent => 3 }

def some_action

render :xml =&gt; SomeModel.all.to_xml( TO_XML_OPTIONS_HASH )

end end

When class caching is on, this causes the TO_XML_OPTIONS_HASH to be modified and the builder in the hash will get appended to every time the action is called.

Comments and changes to this ticket

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>