Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Altered Rails Route Globbing breaks when non-strings passed

#172

Not sure about the this consequences of this, but ...

Ticket #144 Bug in Rails Route Globbing implemented in 6776edccf6fb553eb0ac6db55e1d30df1b5b6589 calls URI.escape on path_component which breaks when path_component is not a String.

E.g. I have a named route url helper containing a *permalink pathsegment to which I pass an array like: [published_at.year, published_at.month, published_at.day, id]. (This worked in 2.0.2)

This breaks with:

private method `gsub' called for 2008:Fixnum

/usr/local/lib/ruby/1.8/uri/common.rb:289:in `escape'

The solution could be to call #to_s on path_component before passing it to URI.escape.

Attached patch implements this change.

Reported by Sven Fuchs · May 12th, 2008 @ 07:27 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik

    Do you have a failing test case ?

    Thanks.

    May 13th, 2008 @ 02:39 PM

  2. Pratik
    Pratik

    And also, it'd be nicer if you create the .diff using git-format-patch, so that you get the credit when patch is committed :)

    May 13th, 2008 @ 02:41 PM

  3. Pratik
    Pratik
    • State changed from new to incomplete

    May 13th, 2008 @ 02:55 PM

  4. Sven Fuchs
    Sven Fuchs

    Sure :)

    Attached patch includes a failing test case as well as the fix and is done with git-format-patch.

    May 13th, 2008 @ 09:12 PM

  5. Rick
    Rick
    • State changed from incomplete to open

    May 13th, 2008 @ 09:13 PM

  6. Pratik
    Pratik

    Committing using .to_param instead of .to_s and minor modification to the test.

    Thanks.

    May 16th, 2008 @ 05:37 PM

  7. Repository
    Repository

    (from [345f030c5b6c0a28ddde56c80a1112b00d345c79]) Ensure routing generator works with non-string keys. [#172 state:resolved]

    Make sure that (with recent correction to globbed parameter escaping) non-string

    values can still be passed route generation helpers for globbed route segments.

    For example, foo_path([1, 2, 3]) should still work for a route like map.foo "*globbed"

    by implicitely calling to_s on the Fixnums.

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    May 16th, 2008 @ 05:37 PM

  8. Pratik
    Pratik
    • State changed from open to resolved

    May 17th, 2008 @ 11:57 AM