Appending empty query string param to the URL in Rails
Posted
by Termopetteri
on Stack Overflow
See other posts from Stack Overflow
or by Termopetteri
Published on 2010-06-12T20:34:35Z
Indexed on
2010/06/12
20:43 UTC
Read the original article
Hit count: 374
Is there a way to append something to the query string with no value set?
I would like to see this kind of URL being generated: http://local/things?magic
.
What I'm looking for is when the user goes to http://local/other?magic
then every URL in the generated page would contain magic
in the end.
Following code is almost a solution but it gives me http://local/things?magic=
. There is an extra =
that I don't want there.
def default_url_options(options)
if params.has_key?("magic")
{ :magic => "" }
end
end
Setting { :magic => nil }
will remove the magic entirely from the generated URLs.
© Stack Overflow or respective owner