RE: Using ? to pass additional parameters
Rich
6-8-2006 17:35
To get additional parameters (such as .../admin/articles?page=2) to work, I did the following:
In ActionPack/lib/ActionController/cgi_process.rb
In Module ActionController, I replaced:
def query_string
if (qs = @cgi.query_string) && !qs.empty?
qs
elsif uri = @env['REQUEST_URI']
parts = uri.split('?')
parts.shift
parts.join('?')
else
@env['QUERY_STRING'] || ''
end
end
with...
def query_string
if (qs = @cgi.query_string) && !qs.empty?
#rbw qs
parts = qs.split('?') #rbw - add
parts.shift #rbw - add
parts.join('?') #rbw - add
elsif uri = @env['REQUEST_URI']
parts = uri.split('?')
parts.shift
parts.join('?')
else
@env['QUERY_STRING'] || ''
end
end
I'm not completely certain this code is right. In your controller or view, the params hash will now contain 'page' with a value of 2, so your controller should work as expected.
But params also still contains the /admin/articles?page variable as well. This seems harmless enough, but since I don't know how it got there, there may be other annoying side-effects that I haven't discovered.
Hope this helps.
Rich