【发布时间】:2013-04-18 17:03:29
【问题描述】:
我可以使用this line at the end of the routes fileredirect所有(无效)网址:
match '*a' => redirect('/')
我想进行重定向并在routes.rb 中传递警报消息。
类似的东西(这里的语法错误):
match '*a' => redirect('/'), :alert => "aaargh, you don't want to go to #{params[:a]}"
可以这样做吗?
如果我在视图/控制器中执行此操作,我可以使用 redirect_to 并在重定向页面上传递一条 flash 消息(参见 redirecting in the docs 中的示例)。创建一个新的控制器方法并在那里重定向可以工作,但它似乎不优雅......这是推荐的方式吗?
【问题讨论】:
标签: ruby-on-rails routes