Run Generate Controller command from a Module

2019-08-29 02:49发布

问题:

I know the basic command to create controllers in Rails is to use Rails generate controller

But in the code I see something like this structure below and was wondering how to do that?

The structure looks like this:

and the generated code looks like this, I need something similar:

module Performance
  class BaseController < ApplicationController
  end
end


module Performance
  class GroupsController < BaseController
    def show
    end

    def index
    end
  end
end

回答1:

To generate namespaced controller you should type, for example:

rails g controller performance/base