This project is archived and is in readonly mode.
Routing Errors won't get rescued properly
Reported by LacKac | January 2nd, 2009 @ 12:23 AM
When requesting an uri with no matching route the application raises the following exception:
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.request=
/Users/LacKac/Working/Lab/test/vendor/rails/actionpack/lib/action_controller/base.rb:518:in `process_without_filters'
Reproducing the error is simple:
- create a blank application
- fire up script/server
- visit http://localhost:3000/wrong_uri
- check you development.log
The problem is that the call_with_exception
method
won't find the original request and response objects in the
env
hash because they're not yet set. I attached a
patch which solves the problem by creating new request and response
objects if they're not set. It's basically the same as in this
commit by josh:
http://github.com/rails/rails/co...
I couldn't come up with a test since not having those two env keys set will create new request and response objects wich will make it impossible to test based on changes made to a TestResponse instance.
Comments and changes to this ticket
-
josh January 2nd, 2009 @ 03:49 AM
- Milestone cleared.
- State changed from new to open
- Assigned user set to josh
-
josh January 2nd, 2009 @ 03:56 AM
Ugh, I knew this was going to causes problems. Thanks for catching it and making the proper patch.
Any chance I could bother you to create some unit tests to go with it? :)
I don't want this to accidently break again.
-
LacKac January 2nd, 2009 @ 05:04 AM
It was tricky since all of the
@controller
,@request
and@response
instance variables are ignored whencall_with_exception
is called but eventually I came up with a test which is based on the return value of the method.It's attached. This also includes the fix so ignore my previous patch.
-
Repository January 2nd, 2009 @ 04:44 PM
- State changed from open to resolved
(from [606176a55b90c27687ae17f40fd1af0a86b62246]) Fixed call_with_exception for Routing Errors [#1684 state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
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
- 1684 Routing Errors won't get rescued properly (from [606176a55b90c27687ae17f40fd1af0a86b62246]) Fixed c...