问题描述
我阅读了帮助&尝试使用以下命令来跳过测试,资产和内容的生成辅助文件
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文件中配置所需的默认值-请参见我如何确保Rails不会为视图和帮助程序生成规范测试? a>.
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?.
这篇关于跳过创建测试,资产&的语法轨道生成控制器的助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!