且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Rails中捕获整个应用程序的ArgumentError?

更新时间:2023-11-24 20:04:28

如果有人仍在寻找答案,我会请参阅此答案
https://***.com/a/25842118/697816

If anyone is still looking for an answer for this, I would refer to this answer https://***.com/a/25842118/697816

application_controller.rb

下rescue_from ActionController :: RoutingError,带有:-> {render_404}

添加

rescue_from ArgumentError,带有:-> {render_404}

这将完全捕获所有 ArgumentError