对于Rack :: Utils:Module,refinerycms undefined方法`escape_path'

时间:2015-07-30 03:51:03

标签: ruby-on-rails refinerycms

我正在将一个在heroku cedar-10上的旧项目升级到cedar-14并准备让它正常工作我不得不升级一些东西。

将refinerycms从1.0.8升级到1.0.11时,在进入炼油厂/图像区域时出现此错误;

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及其所有朋友。不像听起来那么有趣。

1 个答案:

答案 0 :(得分:1)

您可以使用缺少的方法扩展旧的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的文件,例如