Rack::Utils:Module 的 refinerycms 未定义方法“escape_path”

refinerycms undefined method `escape_path' for Rack::Utils:Module

我正在将 heroku cedar-10 上的一个旧项目升级到 cedar-14,为了让它正常工作,我不得不升级了很多东西。

将 refinerycms 从 1.0.8 升级到 1.0.11 时,我在前往 refinery/images 区域时遇到此错误;

undefined method `escape_path' for Rack::Utils:Module

Extracted source (around line #4): 

Rendered /usr/local/rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/refinerycms-images-1.0.11/app/views/admin/images/index.html.erb within layouts/admin (360.1ms)
Completed 500 Internal Server Error in 454ms

ActionView::Template::Error (undefined method `escape_path' for Rack::Utils:Module):
    1: <ul id="image_grid" class="<%= ['clearfix', 'pagination_frame', pagination_css_class].compact.join(' ') %>">
    2:   <% @images.each_with_index do |image, index| -%>
    3:     <li id="image_<%= image.id %>" class='image_<%= index % 5 %>'>
    4:       <%= image_fu image, '135x135#c', :title => image.title %>
    5:       <span class='actions'>
    6:         <%= link_to refinery_icon_tag('eye.png'), image.url,
    7:                     :target => "_blank",


Rendered /usr/local/rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.7ms)
Rendered /usr/local/rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (6.2ms)
Rendered /usr/local/rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (11.6ms)

更新

我尝试更新机架,但 rails 3.0.20 依赖机架 1.2.5,机架 1.2.5 不包含 escape_path 方法!

现在我想知道是不是很容易猴子补丁架或升级到rails 3.1 更新到 rails 3.1 虽然似乎需要更新 refinerycms 及其所有朋友。并不像听起来那么有趣。

您可以使用缺少的方法扩展旧的 Rack::Utils 模块。

require 'rack/utils'

module Rack
  module Utils
    def escape_path(s)
      escape(s).gsub('+', '%20')
    end
    module_function :escape_path
  end
end

例如将其添加到 config/initializers 到名为 expand_rack.rb 的文件中