Better nested resource routes for Rails

If you’re like me, you’ve found nested resource routes to be a little clunky.  If a user has many posts, and a post has many comments, you’d often want a url that looks like http://example.com/users/1/posts/7/comments/1000.  However, the helper to generate that url looks like user_post_comment_url(user, post, comment).

That’s a lot to type, and the default scaffolds don’t respect this.  They create url helpers like comment_url(comment), even though that may not actually exist.

Enter collapsed_routes!  This gem generates the simpler versions of the url helpers, while keeping the hierarchy intact.

README on Github
:$ sudo gem install fizx-collapsed_routes

Leave a comment