Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7462 (closed enhancement: duplicate)

Opened 2 years ago

Last modified 2 years ago

[PATCH] url_for fix to generate parameter sets for hashes and arrays

Reported by: bgipsy Assigned to: core
Priority: normal Milestone: 1.x
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc: dkubb

Description

This patch fixes behaviour described in http://dev.rubyonrails.org/ticket/7047 and makes it possible to unclude hashes (and recursive hashes with arrays too) into url options.

build_query_string() was refactored and to_param() call was moved from options_as_params() to DymanicSegment::extract_value.

As I can imagine, to_param conversion on raw options-hash, done in options_as_params() is too early and blocks build_query_string() from doing its work. This patch considers that value conversion is a responsibility of corresponding segments and query options that don't have their segments. PathSegment, being a descendant of DynamicSegment, gets its array to_param'ed too.

test cases included

Attachments

url_for_arrays_and_hashes.diff (5.3 kB) - added by bgipsy on 02/02/07 13:16:58.

Change History

02/02/07 13:16:58 changed by bgipsy

  • attachment url_for_arrays_and_hashes.diff added.

03/04/07 01:10:01 changed by dkubb

+1 on the idea of url_for properly outputting nested and array params. I would love this.

However, wasn't a to_query method added in [6038] that can do alot of what this patch does? Would it be better to rework the patch to use that instead?

03/04/07 01:10:33 changed by dkubb

  • cc set to dkubb.

03/04/07 03:23:27 changed by bitsweat

  • status changed from new to closed.
  • resolution set to duplicate.

Looking good. Please follow up in the original #7047 with a patch using #to_query. Thanks!