What people tend to do is to handle exception in controller with rescue_from, well it is totally fine. However there is also a different way by delegating the handling to router.
Configure the app to handle exception with Router
# config/application.rb
config.exceptions_app = self.routes