从模块运行生成控制器命令 [英] Run Generate Controller command from a Module
本文介绍了从模块运行生成控制器命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道在 Rails 中创建控制器的基本命令是使用 Rails generate controller
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?
结构如下:
生成的代码看起来像这样,我需要类似的东西:
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
推荐答案
要生成命名空间控制器,您应该键入,例如:
To generate namespaced controller you should type, for example:
rails g controller performance/base
这篇关于从模块运行生成控制器命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文