RoR REST HTTP PUT: XML payload option?

I’m attempting to create a RESTful Web service using 1.2.2. I would
like to be able to update a model via an XML payload PUT to the
controller, but the scaffold_resource PUT handler
(MyController#update) seems to only work with values of the form
“modelname[columname]=value”. If I supply anything else – such as the
same XML that the scaffolded GET returns – it gets ignored by the

I’m guessing that I need to roll my own #update, which is fine. How
can I get my hands on the raw data sent over by the PUT invocation? Or
is there a better way of accomplishing this?


Mark Murphy
[email protected]

I figured it out by poking through the ActiveController::Base source.

To make this work, you have to specify “Content-type: application/xml”
in the HTTP PUT request. This triggers logic set up by default in the
ActionController::Base.param_parsers hash to parse the XML and put it
in the params hash for the REST controller to use.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs