I'm trying to reproduce a cURL to POST an array of hashes and having trouble with the syntax. This is the basic format I want:
curl -X POST http://localhost:3000/api/v1/shops -d \
"shop[users][]=1 \
&shop[users][]=2\
&shop[users][]=c"
How do I turn the values 1, 2, and c into hashes?
On my Rails API, I want the object to look like this:
{
shop: {
users: [
{
name: "Foo",
age: 34
},
{
name: "Bar",
age: 12
}
]
}
}
Update
I tried the here-doc solution below but Rails parses that wrong, giving me:
{"{ shop: { users: "=>{" { name: \"Foo\", age: 34 }, { name: \"Bar\", age: 12 } "=>{" }}"=>nil}},"action"=>"create", "controller"=>"shops"}