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.
Edited due to the changed question on the comment below:
Ah I see.
You could easily use the same URL for all devices and just separate by checking the request environment for
HTTP_USER_AGENT.But if this distinction is not enough (I think it is enough for more than 80% of all cases) you could do the following:
in
config/routes.rb:I have not tested this, but maybe you will have to add a MIME type mapping for :format => ‘mobile’.