开发者

Rails - What is right way to do a show page for a nested resource

since I am only going to be showing that one item, do I just have (example)

/the_thing/23

or do I still go with the /the_group/1/the_thing/23

I know I need to appropriately nest and have associations for forms and using nested routes for links, but fo开发者_如何学Gor a show page is my link to it nested or not?

i.e. should I still show it within the context of its master or just on it's own. In this case the resource cannot be updated without the nesting i.e. on it's own.

Will a main intent be to show links back to the group?

This question is ONLY about the show page.


This is just a matter of choice, you can even create both routes depending on the context.

You should just ask yourself if it makes more sense for the user to see one url or the other: it's sheer user experience here.


It's true that it's only a matter of choice.

But consider a case, you have a Post model and Comment model, and Comment is a nested resource of Post. It does not make sense to have a separate route for show action of Comment, as showing comments without the relevant post makes no sense.

Hence, it's case specific as well.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜