我读了《帮助与帮助》;try 使用以下命令跳过测试、assets资源 和;助手文件

$ 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个.但最后两行很有趣:

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

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

推荐答案

try 使用--no-optionname:

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

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?.

Ruby-on-rails相关问答推荐

使用Hotwire/Turbo的Rails在链接悬停时获取请求

Ubuntu Webhooks无法读取安装的正确RVM Ruby

多对多模型通过控制台创建记录不起作用

具有 IN 子句的参数化查询在 ruby​​-on-rails 的 blazer 工具中无法按预期工作

Sweet Alert 2 在 Rails 7 应用程序中无法正常工作

Gem::Ext::BuildError:ERROR:无法在macOS Monterey上构建Gem本机扩展

Rails ActiveRecord 中的更新插入

Rails 和 jsonb 类型jsonb不存在

您将如何在 Ruby on Rails 应用程序中使用 rSpec 测试观察者?

如何在 Rails 中使用延迟作业(job)取消预定作业(job)?

Ruby/Rails 中的类方法与常量

如何从 Rails 路由中删除控制器名称?

Rails 和 OS X:如何安装 rmagick?

RSpec > 有没有办法用一个命令运行所有测试?

Rails 4 迁移:如何重新排序列

Rails 3. 构建 oauth2 提供程序

submit_tag rails 表单中的 bootstrap 图标

如何一次显示一条 Ruby on Rails 表单验证错误消息?

如何创建一个 ruby​​ Hello 世界?

是否可以输出rake db:migrate产生的 SQL 更改脚本?