Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试使用另一个分隔符创建 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) %>
<%= link_to 'Category', show_category_path(category) %>
匹配'/category-food'到:'category#food'。
'/category-food'
'category#food'