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
Post a Comment