Try :
get "/sample" => "posts#show", id: 2
Mask Slug in Rails Routes
-
03-10-2022 - |
题
I am trying to mask a url of a show action in a controller with an id to just "sample" but it won't mask:
get '/sample' => redirect("/posts/2"), :as => '/sample'
What's wrong with the above?
解决方案
不隶属于 StackOverflow