How to switch route namespace in Rails? -


i have following router:

scope ':name'                              # category :name   :animators, controller: 'categories'   :creators, controller: 'categories'    resources :items, only: [:show] end 

it generates following urls:

http://localhost:3000/birthday/ # index page http://localhost:3000/birthday/item/123 # resource show page 

however make second url this

http://localhost:3000/birthday/animator/123 # resource show page 

on item model animator :type

if inner scope

scope ':type'   resources :items, only: [:show] end 

i get

http://localhost:3000/birthday/animator/item/123 

but rid of item, plus makes me indicate additional parameter when using link_to in view, not good.

scope ':name'                                                                 :animators, controller: 'categories'                                       :creators, controller: 'categories'                                         resources :items, only: [:show]                                                '/animator/:id' => 'animator#show'                                                                                                  end 

resources :items, only: [:show] catch routes /birthday/items/1, /birthday/items/2 etc. while get '/animator/:id' => 'animator#show able catch routes have mentioned in question:

http://localhost:3000/birthday/animator/123   

Comments