How to change the name of a route in Ruby on Rails

I work in a RoR project, and I have several routes that I want to change, how these route routes are displayed in the browser.

My route:

get 'campaigns/:slug' => 'campaigns#show'

Result:

http://localhost:3000/campaigns/cdlcuiaba

What I want:

http://localhost:3000/cdlcuiaba

thanks

+4
source share
1 answer

Be warned that this is highly discouraged, but can be done as follows (order of questions):

get '/admin' => 'admin:show'
get '/:slug' => 'campaigns#show'

EDIT. , , /admin campaigns#show, , . , - , .

+5

Source: https://habr.com/ru/post/1608692/


All Articles