ruby on rails - What all exceptions map to 404.html and what exceptions map to 500.html -


i using rails3 , looking list of exceptions show 404.html , list of exceptions map 500.html in production mode.

right need add like

rescue_from activerecord::recordnotfound, :with => :render_404 

in application_controller , don't it. think rails should handle automatically.

i'm doing in application controller:

rescue_from exception, :with => :handle_error  def handle_error(exception)   if exceptions_to_treat_as_404.include?(exception.class)     render_404   else     raise exception if rails.env == 'development'     body = exception_error_message(exception)      #to logger     logger.fatal( body )      #to email     = '<errors@peakdemocracy.com>'     recipients = "<robert@peakdemocracy.com>"     subject = "[error] (#{exception.class}) #{exception.message.inspect}"     genericemail.create(:subject => subject, :from => from, :recipients => recipients, :body => body)      #to pagerequest table     log_request(true)      #render error message     render_500   end end   def exceptions_to_treat_as_404   exceptions = [abstractcontroller::actionnotfound,       activerecord::recordnotfound,                 actioncontroller::unknowncontroller,                 uri::invalidurierror,                 actioncontroller::unknownaction]   exceptions << actioncontroller::routingerror if actioncontroller.const_defined?(:routingerror)   exceptions end 

Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -