开发者

Ruby on Rails: Rest API to submit a list?

I am confused about RoR's handling of REST lists.

The Rails 3 routes magic creates (among others)

POST /items create one item
GET  /items list all items

Now, I want to have exactly this PLUS the possibility to POST a list of items (in XML).

What's the best way to do it?

Semantically, POST /items to me sounds about creating a list, not a single item Can I '开发者_StackOverflow社区overload' this in the controller? Or do I need to create a new routing?

Thanks


You can code your controller to either accept a single item or an array of them. This isn't in any way reflected in the routes, but only concerns your controller, as POST-parameters are not specified in the routes.

It is accepted (and generally assumed) behavior to accept a single item there. But you are free to accept whatever you like.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜