跳过创建测试,资产&的语法轨道生成控制器的助手? [英] Syntax to skip creating tests, assets & helpers for `rails generate controller`?

查看:104
本文介绍了跳过创建测试,资产&的语法轨道生成控制器的助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了帮助&尝试使用以下命令来跳过测试,资产和内容的生成辅助文件

I read the help & tried the following command to skip generation of tests, assets & helper files

$ bin/rails generate controller home index  --helper false --assets false --controller-specs false --view-specs false   
create- app/controllers/home_controller.rb
        route  get "home/index"
        invoke  erb
        create    app/views/home
        create    app/views/home/index.html.erb
        invoke  rspec
        error  false [not found]
        error  false [not found]

您可能会在上面的输出中注意到,&仅controller, routes&生成views.但由于最后两行很有趣:

As you may notice by output above this works & only controller, routes & views are generated. But as last two lines are interesting:

error  false [not found]
error  false [not found]

显然,rails似乎不喜欢--option-name false语法.所以这个错误是因为我使用了错误的语法?如果是,那正确的方法是什么?谢谢

Obviously rails doesn't seem to like --option-name false syntax. so this this error because I used the wrong syntax? If yes, then what is the correct way? Thanks

推荐答案

尝试使用--no-,然后使用optionname:

rails generate controller home index  --no-helper --no-assets --no-controller-specs --no-view-specs

如果您想在每次运行generator命令时更改默认行为,则可以在application.rb文件中配置所需的默认值-请参见

If you want to change the default behavior every time you run the generator command, you can configure the defaults you would like in the application.rb file - see How can I make sure Rails doesn't generate spec tests for views and helpers?.

这篇关于跳过创建测试,资产&的语法轨道生成控制器的助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆