RESTfully Nesting Resource Routes with Single Identifiers

前端 未结 4 1902
情话喂你
情话喂你 2021-02-06 04:47

In my Rails app I have a fairly standard has_many relationship between two entities. A Foo has zero or more Bars; a Bar belongs to exactly

4条回答
  •  北海茫月
    2021-02-06 05:18

    You're looking for shallow routes. As you pointed out, the idea of having a deeply nested route for things like creates, updates is unnecessary since you are targeting the desired record directly.

    I have never actually done the shallow routing thing so I'll pass on the railscast episode where Ryan Bates explains it probably better than I could: 139 Nested Resources.

    Edit: You can read up a little more on the guides for routing 3.8.4.

提交回复
热议问题