Ruby on rails 替换URI.escape后发生CGI::escape错误

Ruby on rails 替换URI.escape后发生CGI::escape错误,ruby-on-rails,ruby,cgi,uri,Ruby On Rails,Ruby,Cgi,Uri,这篇文章讨论的是将URI.escape替换为CGI::escape,因为URI.escape已经过时了。在我们的rails3.2应用程序中,URI.escape用于重定向到。我们的rails应用程序中有两个案例: URI.escape(SUBURI + '/user_menus') URI.escape(SUBURI + '/authentify/signin') 以下是路由中的匹配项。rb: match '/signin', :to => 'authentify::sessions#

这篇文章讨论的是将URI.escape替换为
CGI::escape
,因为URI.escape已经过时了。在我们的
rails3.2
应用程序中,
URI.escape
用于
重定向到
。我们的rails应用程序中有两个案例:

URI.escape(SUBURI + '/user_menus')
URI.escape(SUBURI + '/authentify/signin')
以下是
路由中的匹配项。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何时将被完全淘汰?

irb(main):001:0>URI.escape('/nbhy/projectx_projects_path')=>“/nbhy/projectx_projects_path”irb(main):002:0>CGI::escape('/nbhy/projectx_projects_path')=>%2Fnbhy%2Fprojectx_projects_projects_path“URL助手”对我们来说是新事物,但如果URL助手是一个可行的解决方案,我确实明白为什么不这样做的原因。目前,我们几乎在应用程序中的每个重定向都使用URL.escape。我们注意到它被弃用了,正在寻找它的等价物。我们正在寻找类似于URI.escape的东西来处理URL escaping.ruby-doc.org/stdlib-2.0.0/libdoc/URI/rdoc/URI/escape.html。ruby 2.0.0中有URI.escape模块。为什么不推荐使用它?/authentify/view\u handler是一种记录访问的上一页的方法。如果您指的是路由生成的路径,那么我们使用的是helper。