OK … so I’m not supposed to use it but …
Why doesn’t rescue_from ActionController::RoutingError work witht he
code from
http://www.rubyplus.org/episodes/20-Extended-RESTful-Authentication-Rails-2-App.html
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
See ActionController::RequestForgeryProtection for details
Uncomment the :secret if you’re not using the cookie session store
protect_from_forgery # :secret => ‘34e000fc7cc2daeae150a89535f7f87d’
Be sure to include AuthenticationSystem in Application Controller
instead
include AuthenticatedSystem
#Shnelvar
debugger # This one gets hit
#neither rescue_from seems to work
rescue_from ActionController::RoutingError, :with => :route_not_found
rescue_from ActionController::RoutingError, :with => :render_404
protected
def route_not_found
debugger #this one does not
render :text => ‘What are you looking for ?’, :status => :not_found
end
#Shnelvar end
end
As I scour the internet for this I see several people having the same
problem and various explanations that make little sense to me.
It gets more interesting in that if I use the most recent authlogic
code:
Filters added to this controller apply to all controllers in the
application.
Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all
helper_method :current_user_session, :current_user
filter_parameter_logging :password, :password_confirmation
private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session &&
current_user_session.record
end
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to new_user_session_url
return false
end
end
def require_no_user
if current_user
store_location
flash[:notice] = "You must be logged out to access this page"
redirect_to account_url
return false
end
end
def store_location
session[:return_to] = request.request_uri
end
def redirect_back_or_default(default)
redirect_to(session[:return_to] || default)
session[:return_to] = nil
end
rescue_from ActionController::RoutingError do
debugger
render :text => ‘no way, Jose’
end
end
the rescue DOES work.
So … my general question is …
How would one go about starting to figure out why it does not work in
the RESTful Authentication?