gpt4 book ai didi

ruby-on-rails - 像 http://host.com/controller-action-controller 这样的 Rails 路由

转载 作者:太空宇宙 更新时间:2023-11-03 18:27:35 24 4
gpt4 key购买 nike

我尝试使用另一个分隔符创建 URL,而不是“/”,例如“-”

来自 http://host.com/category/food => http://host.com/category-food

谁能帮帮我?

谢谢

最佳答案

像这样的东西应该适用于 Rails 3.0 及更高版本:

 get 'category-:id' => 'categories#show', :as => 'show_category'

然后您可以使用 <%= link_to 'Category', show_category_path(category) %> 链接到它

关于ruby-on-rails - 像 http://host.com/controller-action-controller 这样的 Rails 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8918262/

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