Add + in URL insteade of space (%20)

Posted by Bhushan Ahire | Posted in Rails | Posted on 22-01-2008

0

This is a workaround to get spaces in URL as pluses not %20 like it is in Rails2.

module ActionController::Routing
  class DynamicSegment
    def interpolation_chunk
      "#{CGI.escape(#{local_name}.to_s)}"

    end

    def match_extraction(next_capture)
      default_value = default ? default.inspect : nil

      %[
        value = if (m = match[#{next_capture}])
          CGI.unescape(m)
        else

          #{default_value}
        end
        params[:#{key}] = value if value
      ]
    end

  end
end

Write a comment

You must be logged in to post a comment.