I am starting to use some nested routes which is definitely a different way of planning things and I'm really failing to see added benefits.
So what are they?
I am starting to use some nested routes which is definitely a different way of planning things and I'm really failing to see added benefits.
So what are they?
It allows you stay Restful and automatically route urls where more than one model is involved.
So if you have a user model that has many posts, you can nest the posts model in the user model and make a call like this
<%=link_to "Users posts", user_posts_path(@user) %>
which would route automagically to the index action of the Posts Controller via
/users/4/posts
passing the user id as a parameter that you can use to display all the posts just for that user.
A good link to get more info http://guides.rubyonrails.org/routing.html#nested-resources