Sha256: b41e58ad9c8eeb1bf066575a4b7f57cc5cc95b5af219398a2a12b434ccff2876

Contents?: true

Size: 877 Bytes

Versions: 43

Compression:

Stored size: 877 Bytes

Contents

module UrlForFix
  # TODO (uwe): Can be removed when using EdgeRails or Rails >= 1.3
  def url_for(org_options = {}, *parameters_for_method_reference)
    return super(org_options, *parameters_for_method_reference) if org_options.nil? || org_options.is_a?(String)
    new_options = {}
    org_options.each do |param, value|
      add_option(new_options, param, value)
    end
    url = super new_options, *parameters_for_method_reference
    url = CGI::unescape(url) if url && org_options[:escape] == false
    url
  end
  
  # Used with AplicationHelper::url_for
  def add_option(options, param, value)
    case value
    when Hash:
      value.each do |key, v|
        add_option(options, "#{param}[#{key}]", v)
      end
    when Array:
      value.each do |v|
        add_option(options, "#{param}[]", v)
      end
    else
      options[param] = value
    end
  end
  
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
backlog-0.37.2 lib/url_for_fix.rb
backlog-0.37.1 lib/url_for_fix.rb
backlog-0.36.2 lib/url_for_fix.rb
backlog-0.16.0 lib/url_for_fix.rb
backlog-0.17.0 lib/url_for_fix.rb
backlog-0.17.1 lib/url_for_fix.rb
backlog-0.17.2 lib/url_for_fix.rb
backlog-0.17.4 lib/url_for_fix.rb
backlog-0.17.3 lib/url_for_fix.rb
backlog-0.17.5 lib/url_for_fix.rb
backlog-0.18.0 lib/url_for_fix.rb
backlog-0.17.6 lib/url_for_fix.rb
backlog-0.19.0 lib/url_for_fix.rb
backlog-0.20.0 lib/url_for_fix.rb
backlog-0.20.1 lib/url_for_fix.rb
backlog-0.21.0 lib/url_for_fix.rb
backlog-0.21.2 lib/url_for_fix.rb
backlog-0.21.1 lib/url_for_fix.rb
backlog-0.21.3 lib/url_for_fix.rb
backlog-0.22.0 lib/url_for_fix.rb