Default URL and nested resources

Say you have resources post and comments, post has many comments. You
are in CommentsController#index because you asked for
/posts/8/comments, and you need to generate a link to self with
additional query string params (in the real applicaction that’s goes
in the header of a listing to provide column ordering).

Back in the controller/action days <%= link_to “current”, :sort_by =>
‘date’ %> worked, but now that links to /comments?sort_by=date, so you
loose the scope over post 8. How would you accomplish that? You cannot
assume anything because the listing may be scoped in diferent ways or
not at all, just need to link to self in a clean way.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs