I know that the long term solution is to try to prevent getting a timeout error. but every now and then on my applicaiton, I am getting a time out error. I have been trying to rescue from it and redirect to the homepage. instead of showing a 404, or a 500 error.
This is what my code looks like
class ApplicationController < ActionController::Base
...
rescue_from Timeout::Error, :with => :rescue_from_timeout
def rescue_from_timeout
redirect_to users_root_path
end
...
end
The problem is that I am still getting the Timeout Error
I normally like to include all the code in the rescue_from block for readability:
class ApplicationController < ActionController::Base
...
rescue_from Timeout::Error do |e|
## log e if needed
return redirect_to users_root_path
end
...
end
That should work as intended (I don't even know if the return is needed)