Appending empty query string param to the URL in Rails
- by Termopetteri
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.