routes - rerouting nested resource in Rails -
i have in routes:
resources :users resources :posts end
it creates show path /users/:user_id/posts/:post_id
great. if types /users/:user_id/post/:post_id
(mind singular /post , not /posts) 404. want 302 redirect .../post/:post_id
../posts/:post_id
in routes. how?
you may able achieve using following in routes config.
get '/users/:user_id/post/:post_id', to: redirect('/users/%{user_id}/posts/%{post_id}')
more info here: http://guides.rubyonrails.org/routing.html section: 3.12 redirection