Forum: Ruby on Rails How to pass and not a parameter to a link?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
04e1b6bf268d6110f4ca25201186f726?d=identicon&s=25 Xdmx Xdmx (xdmx)
on 2009-01-06 13:56
Hi, i've a page where when a params[:something] is passed all/some the
urls in that page must have the params[:something] too, but when there
isn't it shouldn't appear.
I've tried with:

report_url(params[:id], :something => params[:something])
this works when there is the params[:something], but it doesn't when
there isn't, as the result is:
http://localhost:300/report/1?something=

So i've tried with
tmp = params[:something] ? {:something => params[:something]} : {}
report_url(params[:id], tmp)

This is better, because works when there is the parameter, and almost
does when there isn't, as the result is:
http://localhost:300/report/1?

Is there any way to have the two results
http://localhost:300/report/1?something=123 and
http://localhost:300/report/1 when there is and there isn't the
parameter? Without having the question mark at the end in the second
case
04e1b6bf268d6110f4ca25201186f726?d=identicon&s=25 Xdmx Xdmx (xdmx)
on 2009-01-12 18:54
anyone? :(
This topic is locked and can not be replied to.