开发者

Backbone.js - Saving individual item in collection - what it the proper REST approach?

I have a model (Parent) which contains a collection of type Child

I'm fetching the model in this way:

GET /parent/:parentId

My question is, what it the standard way to update an 开发者_如何学Cindividual child? Should the URL look something like?:

PUT /parent/:parentId/child/:childId


Yes you are doing it right. Have a look at the rails guide http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions it contains some examples.

You can also flatten all resources. So the child is accessed from /child/:id like the parent. This way the child can be added to multiple objects. For example an address can be associated to a contact or a company.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜