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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

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