how to add namespace to route file using custom generators

97 views Asked by At

I am generating certains controllers using rails generators, it is working as expected.

However, how can i add namespace based routes in my route file

something like


  namespace :api do
    namespace :v1 do
     get resource_one, to: resource_one_index
     get resource_two, to: resource_two_index
    end
  end

I see the following in the documenation under the route section route "resources :people" but i am not sure how to add namespace routing.

Thanks.

1

There are 1 answers

0
Sergey Sokolov On
route "resources :people", namespace: ["api", "v1"]

from your generator leads to result:

route  namespace :api do
            namespace :v1 do
              resources :people
            end
          end

(at least for Rails 7)