Routing Routing and Namespace

For a simple route with names

  map.namespace :api do |api|
    api.resources :genres
  end

how can i reuse this block, but with a different namespace?

I am currently achieving this by writing another route hacked on the fly

  map.with_options :name_prefix => 'mobile_', :path_prefix => 'mobile' do |mobile|
    mobile.resources :genres, :controller => 'api/genres'
  end

But he seems less than ideal.

+3
source share
1 answer

I believe the :: controller => 'api / genres' option is your only approach. Only the cleanup that I see is: map.namespace: mobile.

+1
source

Source: https://habr.com/ru/post/1735692/


All Articles