routes - Rails : add namespace to resource -


i have in routes.rb :

namespace :api   namespace :v1    namespace :me     # ...     resources :offers      resources :state, only: %i(index)     end   end  end end 

this gives me route :

get v1/me/offers/:offer_id/state(.:format) api/v1/me/state#index 

but route have 1 :

get v1/me/offers/:offer_id/state(.:format) api/v1/me/offers/state#index 

simply put, want able place state_controller.rb in offers folder, without changing path access it. how can achieve ?

you should define controller resources explicitly:

resources :state, controller: 'offers/state' 

this route requests app/controllers/api/v1/me/offers/state_controller.rb.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -