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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Xdmx X. (Guest)
on 2009-01-06 14: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:

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:

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
Xdmx X. (Guest)
on 2009-01-12 19:54
anyone? :(
This topic is locked and can not be replied to.