Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple paths for one Rails resource

Is it possible to send multiple paths to the same resource in Rails?

Example: route both '/foo-bars' and '/foo_bars' to resource :foo_bars

like image 516
Asherlc Avatar asked Jan 04 '16 20:01

Asherlc


1 Answers

Maybe you'd prefer a permanent redirect instead? Browsers will cache it and possibly less maintenance problems you'll have later on (1 path = 1 resource is something rails programmers typically take for granted)

http://guides.rubyonrails.org/routing.html#redirection

 get '/stories/:name', to: redirect('/articles/%{name}')
like image 61
bbozo Avatar answered Oct 26 '22 08:10

bbozo