Rails, path_names and nested resources

My routes:

resources :events, :path_names => { :new => "organize" } do resources :forums end 

With these routes, I get URLs like /events/:event_id/forums/organize . I don't want path_names propagating to my nested routes ... Should I override path_names for them? Or use scope ?

 resources :events, :path_names => { :new => "organize" } do scope :path_names => { :new => "new" } do resources :forums # other nested resources... end end 

Or (my favorite, until you find the best solution;))

 resources :events, :path_names => { :new => "organize" } resources :events, :only => [] do #nested resources... end 

Is there a more elegant way to do this? if you don’t think so, you can also tell me which one is the best in your opinion.

+4
source share
1 answer

I used the last option:

 resources :events, :path_names => { :new => "organize" } resources :events, :only => [] do #nested resources... end 
0
source

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


All Articles