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

Ticket #8562 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Restore recognition for symbol keys in methods like url_for and redirect_to that rely on options_as_params

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

Description

This patch restores the parameter conversion code lost in changeset [6343] that causes url_for, redirect_to, and other methods that rely on options_as_params to call to_param on each option. Not having this here breaks compatibility with application that utilize a symbol instead of a string in calls like redirect_to(:controller => :home) .

Attachments

add_recognition_for_symbol_parameters.diff (1.2 kB) - added by JustinLynn on 06/04/07 07:54:50.
add_recognition_for_symbol_parameters_v2.patch (1.3 kB) - added by tarmo on 08/20/07 00:39:04.
Simplified patch to fix some test failures

Change History

06/04/07 07:54:50 changed by JustinLynn

  • attachment add_recognition_for_symbol_parameters.diff added.

08/20/07 00:37:41 changed by tarmo

  • cc set to tarmo.

The patch here currently causes these actionpack tests to fail:

test_array_parameter(UrlWriterTests)
test_hash_parameter(UrlWriterTests)
test_hash_recursive_and_array_parameters(UrlWriterTests)
test_hash_recursive_parameters(UrlWriterTests)

The main issue appears to be that options[:controller] does not get turned into a string when it is a symbol (unlike options[:action] which does get converted). It's a problem because later the routing code tries to remove a slash from in front of the controller name and that fails if the name is a string. So the problem is easily fixed by just converting options[:controller] instead of every parameter.

I'll upload a patch for this.

08/20/07 00:39:04 changed by tarmo

  • attachment add_recognition_for_symbol_parameters_v2.patch added.

Simplified patch to fix some test failures

10/07/07 19:04:25 changed by bitsweat

These patches take different approaches. Why? Is only converting the controller appropriate?

10/07/07 19:12:06 changed by bitsweat

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

(In [7776]) Fix url_for, redirect_to, etc. with :controller => :symbol instead of 'string'. Closes #8562, #9525.

10/08/07 04:42:05 changed by JustinLynn

Well, my first patch converted all parameters, tarmo's patch actually fixes the problem more specifically but still allows for :action => :some_symbol to be called as well as :controller => :some_symbol. Tarmo's method was a better fix in my opinion.