This project is archived and is in readonly mode.

#472 ✓resolved
Cheah Chu Yeow

Fix url_for(nil) crashing

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

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.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages