Query parameters with url_for?

randomguy picture randomguy · Feb 17, 2011 · Viewed 22.8k times · Source
url_for([:edit, @post])

is working and generating /comments/123/edit. Now I need to add a query parameter, so that instead of

/comments/123/edit

it is

/comments/123/edit?qp=asdf

I tried url_for([:edit, @post], :qp => "asdf") but no go.

Answer

Simone Carletti picture Simone Carletti · Feb 17, 2011

Use named routes.

edit_post_path(@post, :qp => "asdf")