Automatic URI encoding on url_for?


I am trying to store a hash in a URL so that a search query can be
stored as a link. Here is my code:

link_to(‘blah’, url_for({:controller => ‘search’,
:action => ‘advanced’,
:query => @query,
:page => n})

@query is the hash I’m trying to store and later retrieve. Right now
it appears to be turning into a plain string with all the keys and
values concatenated together. I want to make it so that query is
automatically freeze-dried into URI-safe stuff and then reconstituted
as an instance variable when the URI is requested again. Any