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.

Fix url_for(nil) crashing

#472
url_for(nil)

will be inferred as the nil_class_url named route - which doesn't exist 99% of the time causing an uncaught exception.

I wasn't trying to use this, just noticed the url_for helper method actually did accept a nil option while reading documentation:

when NilClass
  url = @controller.send(:url_for, nil)

I looked back at http://dev.rubyonrails.org/ticke... and I made a guess that the best way to respond to a nil argument is to assume you want the current url.

Patch attached.

Reported by Cheah Chu Yeow · June 23rd, 2008 @ 02:02 PM

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

Activity

  1. Repository
    Repository
    • State changed from new to resolved
    • Tag set to actionpack, patch, tiny

    (from [96708af6a58a48c2324a3bf8d34232bc29b398c9]) Ensure url_for(nil) falls back to url_for({}). [#472 state:resolved]

    Signed-off-by: Pratik Naik

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

    July 9th, 2008 @ 01:25 PM

  2. Repository
    Repository

    (from [4fa6615b15451fcdea17b33ebd78e3f4a848e4e7]) Ensure url_for(nil) falls back to url_for({}). [#472 Fix url_for(nil) crashing state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    August 25th, 2008 @ 09:27 AM