替换URI.escape后的CGI :: escape错误

时间:2013-11-04 04:39:56

标签: ruby-on-rails ruby cgi uri

What's the difference between URI.escape and CGI.escape?这篇文章讨论的是将URI.escape替换为CGI::escape,因为URI.escape已经过时了。在我们的rails 3.2应用中,URI.escape用于redirect_to。以下是我们的rails应用程序中的两种情况:

URI.escape(SUBURI + '/user_menus')
URI.escape(SUBURI + '/authentify/signin')

以下是routes.rb中的匹配:

match '/signin',  :to => 'authentify::sessions#new'
match '/user_menus', :to => 'user_menus#index'
match '/view_handler', :to => 'authentify::application#view_handler'

替换为CGI::escape后,出现错误:

 ERROR URI::InvalidURIError: the scheme http does not accept registry part:

删除CGI::escape后,错误消失。另一个例子:

redirect_to CGI::escape(SUBURI + "/authentify/view_handler?index=0&msg=Insufficient Access Right! for action=#{action} and resource=#{resource}")

用CGI :: escape替换后,出现错误(如上所述)。

上面使用CGI :: escape出了什么问题? URI.escape的确切等价物是什么? ? URI.escape什么时候才能完全淘汰?

0 个答案:

没有答案