似乎爲我
ruby-1.8.7-p249 > require 'uri'
=> true
ruby-1.8.7-p249 > require 'cgi'
=> true
ruby-1.8.7-p249 > uri = URI.parse("http://www.google.com/url?sa=X&q=http://nashville.broadwayworld.com/article/Just_in_time_for_Halloween_Circle_Players_does_JEKYLL_HYDE_20101013&ct=ga&cad=:s7:f1:v1:d2:i0:lt:e0:p0:t1286988171:&cd=yQoOdKUFTLo&usg=AFQjCNEg2inHF8hXGEvG-TxMQyMx7YGHkA")
=> #<URI::HTTP:0x10127b288 URL:http://www.google.com/url?sa=X&q=http://nashville.broadwayworld.com/article/Just_in_time_for_Halloween_Circle_Players_does_JEKYLL_HYDE_20101013&ct=ga&cad=:s7:f1:v1:d2:i0:lt:e0:p0:t1286988171:&cd=yQoOdKUFTLo&usg=AFQjCNEg2inHF8hXGEvG-TxMQyMx7YGHkA>
ruby-1.8.7-p249 > uri_params = CGI.parse(uri.query)
=> {"cd"=>["yQoOdKUFTLo"], "sa"=>["X"], "cad"=>[":s7:f1:v1:d2:i0:lt:e0:p0:t1286988171:"], "ct"=>["ga"], "q"=>["http://nashville.broadwayworld.com/article/Just_in_time_for_Halloween_Circle_Players_does_JEKYLL_HYDE_20101013"], "usg"=>["AFQjCNEg2inHF8hXGEvG-TxMQyMx7YGHkA"]}
ruby-1.8.7-p249 > uri_params['q']
=> ["http://nashville.broadwayworld.com/article/Just_in_time_for_Halloween_Circle_Players_does_JEKYLL_HYDE_20101013"]
正如傑德施耐德指出工作。你發佈的確切例子在irb中有效。我懷疑的是,你可能以這種或那種方式將輸入URI.parse作爲用戶的參數。我有一個使用Sinatra的類似問題,必須在使用URL.parse之前通過CGI :: unescape傳遞url字符串。 – maz 2010-10-13 20:21:59