Billee D. wrote:
Hi Ralph,
I have to agree with Marnen on this issue; Rails already deals with
routing errors pretty well. But, I understand that you may want to get
your head around why the rescue_from ActionController::RoutingError
call doesn't work in certain situations. I also understand the need to
want to do something programmatically to log or handle the failed
request.
Really, it was -- in the beginning -- a matter of curiosity as to WHY
something didn't work rather than any great need to deal with an issue.
It was, in addition, a general request for how one would go about
solving why.
Suddenly, though, it morphed into a security issue that "I picked that
out of the air" and realized that I really did want to deal with that
security issue.
As a newbie, I find your comments so far very illuminating and helpful.
I think that Marnen is on the right track in that what you are trying
to accomplish with the rescue_from call isn't really the right way to
approach the situation. You want either the rescue_action or
rescue_action_in_public calls instead. I've never used them -- never
had a need for them that I'm aware of -- but the API docs on these
methods seem to tell me this is what you want instead of rescue_from.
Ok, remembering that I am a newbie, please explain _why_ rescue_action
is better/preferred/etc. than rescue_from.
I'm guessing here that you really want to be able to track and keep a
record of all the URLs in your app/site that might trigger a 404 or
could be considered "probing the armor" for weaknesses.
Speaking of this, I was delighted to find this relatively easy-to-read
article on security issues that was installed in my authlogic sample.
... \authlogic\vendor\rails\railties\guides\source\security.textile
This may be a bit off from your original path, but have you considered
trying to catch and trap all 404 errors? I use a technique derived
from Advanced Rails Recipes (Pragmatic Bookshelf: By Developers, For Developers
fr_arr) where I set up a glob route at the bottom of my routes.rb
file:
It is off the original path but ...
I like! I like!
map.connect '*path', :controller => 'four_o_fours'
Then create a controller and model to handle these requests:
[snip]
def self.down
drop_table :four_o_fours
end
end
==================================================
Set this up and you can have a fairly decent trace log of errant
requests right in the database. You can also extend this logic and
setup other controllers for different errors and more. For example, I
have logic set up that will email me if a certain 404 error is
accessed more than 10 times in a minute so I can either fix the
problem or investigate the issue (e.g. a "probe" request).
Nice! Nice! Nice!
I guess this is all just to point out that routing errors are already
pretty easy to manage and maybe what you are really trying to achieve
requires a different approach. 
But ... I still don't understand why it is a better approach.
Clearly you and Marnen Laibow-Koser understand why rescue from is bad
bad bad ... but I an still clueless as to what principle or principles I
am breaking.