'how to add namespace to route file using custom generators

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source