Don't create view folder on rails generate controller

后端 未结 4 941
情歌与酒
情歌与酒 2021-01-31 08:56

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?

4条回答
  •  长发绾君心
    2021-01-31 09:48

    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
    

    demo on a dummy app:

    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
    

提交回复
热议问题