【问题标题】:How to avoid to generate usefulness stuff in rails如何避免在 Rails 中生成有用的东西
【发布时间】:2013-02-09 05:39:04
【问题描述】:

当我运行命令时

rails g controller admin/inbox

它生成 test_unit 和 helper/test_unit。但我不想生成它。在生成控制器期间如何避免它

  create  app/controllers/admin/inbox_controller.rb
  invoke  erb
  create    app/views/admin/inbox
  invoke  test_unit
  create    test/functional/admin/inbox_controller_test.rb
  invoke  helper
  create    app/helpers/admin/inbox_helper.rb
  invoke    test_unit
  create      test/unit/helpers/admin/inbox_helper_test.rb
  invoke  assets
  invoke    coffee
  create      app/assets/javascripts/admin/inbox.js.coffee
  invoke    scss
  create      app/assets/stylesheets/admin/inbox.css.scss

【问题讨论】:

标签: ruby-on-rails ruby-on-rails-3


【解决方案1】:

您可以通过像这样配置config/application.rb 来自定义您的工作流程..

config.generators do |g|
  g.orm             :active_record
  g.template_engine :erb
  g.test_framework  :test_unit, :fixture => false
  g.stylesheets     false
end

更多详情请访问http://guides.rubyonrails.org/generators.html

【讨论】:

    【解决方案2】:

    如果出于某种原因,您只想跳过测试生成一次,您可以这样做:

    rails g controller admin/index --skip-test-framework
    

    rails g controller admin/index --no-test-framework
    

    the documentation for Generators::Base 对此进行了介绍。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-01
      • 2014-10-17
      • 1970-01-01
      • 2012-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多