Currently I have the usual Controller/Action structure:
BlogController:
/blog/list
/blog/create
/blog/detail/my-blog-hash
And PostController
/post/create
/post/detail/my-post-hash
What I would like is a URL for the blog post detail view:
/blog/detail/my-blog-hash/post/my-post-hash
I know there is a RESTBundle, but this is overcomplicating things IMO and there are some real issues with routes and form validation which I was not able to solve (even with help of the guys on IRC). I don't need accesspoints for JSON, serializers, special views etc., I just need a way to stack controllers somehow.
Can someone help me with this?
This doesn't answer your specific question but I wanted to recommend a cleaner URL design that is more RESTful.
To work with blogs in general interact with the /blogs
base resource.
POST /blogs
to create a blog.
GET /blogs
to list all the blogs.
To work with a specific blog you then specify which blog.
GET /blogs/:id
to get the details for the specific blog.
Now specific which subresource of blogs you want to interact with.
POST /blogs/:id/posts
to create a new post.
GET /blogs/:id/posts/:id
to get details of a specific post for a specific blog.
Thinking RESTfully, you have two resources: blogs and posts.
In a RESTful route, the action is implied by the http verb. I understand you are not in Rails, but these simple tables illustrate the "Rails way" of doing REST and RESTful nested resources:
http://edgeguides.rubyonrails.org/routing.html#crud-verbs-and-actions
http://edgeguides.rubyonrails.org/routing.html#nested-resources
Very clean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With