echo '<request><item attribute="foo">bar</item></request>' | curl -X POST -H 'Content-type: application/xml' -d @-

My Rails application forgets all about the attribute when it receives the posted XML.

Processing BazController#evaluate (for at 2009-10-03 18:29:32) [POST]
  Parameters: {"request"=>{"item"=>"bar"}}

Any idea what I'm doing wrong?


Hrm... I think this Rails ticket with its associated patch is relevant to this problem.

Brad Beattie
I think it probably is. Unfortunately as howardk notes in that discussion: "This is a fundamental problem in Rails -- Hash.from_xml just isn't very XML savvy."
Peter Wagenet
+1  A: 

Given that Hash.from_xml isn't very savvy you could try grabbing the raw XML before Rails messes with it. From the controller, you should be able to do request.raw_post. I think that will get you what you want, though there are other similar method that may be better suited. Once you get the raw XML then you can parse it yourself as necessary.

Peter Wagenet