Sha256: 09c80ae61d844df7358bbb071115ea455d380a8091b8bdf96a0f329dec6b9c8a

Contents?: true

Size: 892 Bytes

Versions: 21

Compression:

Stored size: 892 Bytes

Contents

module UrlForFix
  # TODO (uwe): Can be removed when using EdgeRails of 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, value|
        add_option(options, "#{param}[#{key}]", value)
      end
    when Array:
      hash.each do |value|
        add_option(options, "#{param}[]", value)
      end
    else
      options[param] = value
    end
  end
  
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
backlog-0.15.1 lib/url_for_fix.rb