gpt4 book ai didi

ruby-on-rails - 将所有路由错误重定向到应用程序的根 URL

转载 作者:行者123 更新时间:2023-12-04 03:59:47 24 4
gpt4 key购买 nike

例如输入:localhost:3000/absurd-non-existing-route如何在 Rails 中获取指向应用程序主页的无效路由?

最佳答案

使用 rescue_from在您的 ApplicationController救援ActionController::RoutingError并在发生时重定向到主页。

目前这在 Rails 3 中不起作用。 A ticket has been filed.

关于ruby-on-rails - 将所有路由错误重定向到应用程序的根 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2986910/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com