nested namespace route going to wrong controller

前端 未结 2 854
无人共我
无人共我 2021-01-24 18:27

Using Rails 3.0.7, I\'m creating an API for our app, and I have this setup:

routes.rb

  namespace :api do
    namespace :v1 do
      match \"connect\" =&         


        
2条回答
  •  天涯浪人
    2021-01-24 18:58

    skip_before_filter also general takes a symbol parameter for the before filter than you wish to skip. Controller names should not have to be unique as long as the proper scoping/namespacing is applied.

    example

    • api/users_controller
    • admin/users_controller
    • users_controller

    then the code per controller

    class Api::V1::UsersController < Api::V1::BaseController
    end
    
    class Admin:UsersController < Admin::BaseController
    end
    
    class UsersController < ApplicationController
    end
    

    Then the routes

    MyApp::Application.routes.draw do
    
    scope :module => "api" do
      namespace :v1 do
        resources :users
      end
    end
    
    namespace :admin do
      resources :users
    end
    
      resources :users
    end
    

提交回复
热议问题