不要在 rails 生成控制器上创建视图文件夹 [英] Don't create view folder on rails generate controller
问题描述
当您运行 rails generate controller
时,有没有办法使用通常的生成器配置来关闭视图文件夹和操作模板的创建?
Is there a way with the usual generators config to turn OFF the creation of the view folders and action templates when you run a rails generate controller
?
我在任何地方都找不到选项和代码 此处 没有显示任何指示.
I can't find an option anywhere and the code here doesn't show me any pointers.
无论如何,我们可能会在某个时候为我们的 API 构建我们自己的控制器/资源生成器,但我很好奇是否有办法在此期间关闭这种烦恼.
We are likely going to be building our own controller / resource generators at some point anyway, for our API, but I was curious if there was a way to turn off this annoyance in the meantime.
推荐答案
这不是一个有据可查的功能,但尝试添加 --skip-template-engine
(别名 --no-template-engine
) 命令的选项.
It's not a well documented feature, but try to add --skip-template-engine
(alias --no-template-engine
) option to the command.
rails generate controller foo bar --skip-template-engine
关于虚拟应用的演示:
rails g controller my_controller index show --no-template-engine
create app/controllers/my_controller_controller.rb
route get "my_controller/show"
route get "my_controller/index"
invoke test_unit
create test/functional/my_controller_controller_test.rb
invoke helper
create app/helpers/my_controller_helper.rb
invoke test_unit
create test/unit/helpers/my_controller_helper_test.rb
invoke assets
invoke coffee
create app/assets/javascripts/my_controller.js.coffee
invoke scss
create app/assets/stylesheets/my_controller.css.scss
这篇关于不要在 rails 生成控制器上创建视图文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!