Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

spaces in URL

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

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS