# Link\_to with changing one single get-param

**URL:** <https://www.ruby-forum.com/t/link-to-with-changing-one-single-get-param/139901>\
**Category:** Rails\
**Created:** [June 8, 2008, 9:49pm UTC](https://www.ruby-forum.com/t/link-to-with-changing-one-single-get-param/139901 "2008-06-08T21:49:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LpLpLp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@LpLpLp](https://www.ruby-forum.com/u/LpLpLp)\
**Post date:** [June 8, 2008, 9:49pm UTC](https://www.ruby-forum.com/t/link-to-with-changing-one-single-get-param/139901/1 "2008-06-08T21:49:56Z")

</div>

Hey…

i want to sort some of my data-tables with an application-helper named  
“sortable(fieldname)”

in this helper i want to define a link with following schema,  
depending on params[:direction]:  
link\_to fieldname, request.url + ‘?order=desc’ (or asc)

but this link isn’t correct if I click on it several times:

[http://localhost:3000/drafts/222/stats\_details?direction=asc?order=Kontakt&direction=desc?order=Kontakt&direction=asc?order=Kontakt&direction=asc?order=Kontakt&direction=asc](http://localhost:3000/drafts/222/stats_details?direction=asc?order=Kontakt&direction=desc?order=Kontakt&direction=asc?order=Kontakt&direction=asc?order=Kontakt&direction=asc)

Can somebody give me a hint?

Thanks!

---

<div class="post-metadata">

**Author:** ![LpLpLp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@LpLpLp](https://www.ruby-forum.com/u/LpLpLp)\
**Post date:** [June 8, 2008, 11:31pm UTC](https://www.ruby-forum.com/t/link-to-with-changing-one-single-get-param/139901/2 "2008-06-08T23:31:08Z")

</div>

found it by myself:

link\_to ‘linkname’, params.merge({ ‘sort’ =\> column, ‘order’ =\>  
order })
