I am designing a rails rest API that I would like to expose either as xml or json. In a specific action, I am submitting a collection of objects like this:
curl -d "<posts><post><title>my title</title></post><post><title>second post</title></post></posts>" localhost:3000/posts -X POST
I thought that this would be translated into
> params[:posts]
[{:title => "my title"}, {:title => "second post"}]
Instead of that I get
{:post => [{:title => "my title"}, {:title => "second post"}]}
The question is then how should I format my xml such that I get this in params[:posts] ?
[{:title => "my title"}, {:title => "second post"}]
I know how to do it in functional tests and json but not xml :(
Looks like the XML in your curl starts with:
rather than:
Edit:
Posting XML as an array in Rails requires type="array" to be added to the array node.