我想把我的分类URL从以下位置重命名为 https:/website.comcategories苹果。 (#1)至
https:/website.comhi-apples-bye。 (#2)
我试图完成两件事。
在SITEMAP和PATH中显示#2的URL。
路由。
resources :categories
get '/hi-:id-bye', to: "categories#show"
然而,我得到的URL https:/website.comcategories苹果。 在网站地图和 https:/website.comhi-apples-bye。 为路径。
如果有任何帮助,我将感激不尽! 我是一个菜鸟...
不知道你是否需要所有的类别资源路由都有相同的路由前缀,但对于你所举的例子,你可以有。
resources :categories # this is to keep the existing REST routes
# outside categories do ... end
get '/hi-:id-bye', to: "categories#show" # this is to add the route you want
更多细节请看本节。https:/guides.rubyonrails.orgrouting.html#non-resourceful-routes。