Ruby-on-rails 如何在rails的命名空间内生成控制器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15043524/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:27:42  来源:igfitidea点击:

How to generate controller inside namespace in rails

ruby-on-railsruby-on-rails-3

提问by Chris Peters

I have namespace adminin controller, and I want to generate a controller inside of the adminfolder. How can i do it with a Rails command?

admin在控制器中有命名空间,我想在admin文件夹内生成一个控制器。我怎样才能用 Rails 命令做到这一点?

回答by Chris Peters

Try rails g controller admin/usersif you want a userscontroller inside of the adminnamespace. Of course, exchange userswith whatever controller name that you'd like.

rails g controller admin/users如果您想要命名空间users内的控制器,请尝试admin。当然,users与您想要的任何控制器名称交换。

回答by Ramiz Raja

Use this command..

使用这个命令..

rails generate controller namespace_name/controller_name

rails generate controller namespace_name/controller_name

回答by ThienSuBS

If you want to gen it:

如果你想生成它:

rails generate controller namespace_name/controller_name

And If you want to rollback this step using:

如果您想使用以下方法回滚此步骤:

rails destroy controller namespace_name/controller_name