gpt4 book ai didi

ruby-on-rails - 在 Rails 中重定向动态路由

转载 作者:行者123 更新时间:2023-12-05 05:27:37 27 4
gpt4 key购买 nike

如何重定向

get '/directory/:alphabet' => redirect('/directory/:alphabet/1') , :constraints => { :alphabet => /[A-Za-z#]/}

这会引发有关字母表的错误。我如何使用我获得的值(value)?

最佳答案

请参阅 http://guides.rubyonrails.org/routing.html#redirection 下的“动态分割”

使用 %{alphabet} 从源读取值

get '/directory/:alphabet' => redirect('/directory/%{alphabet}/1') , :constraints => { :alphabet => /[A-Za-z#]/}

关于ruby-on-rails - 在 Rails 中重定向动态路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18548185/

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