How to prevent Rails controller generator to modify config/routes.rb

后端 未结 7 1828
Happy的楠姐
Happy的楠姐 2021-01-11 13:27

Sometimes I run a command like rails g controller foo index to generate skeletons for controller and template.

Because I don\'t want to have helpers and

相关标签:
7条回答
  • 2021-01-11 14:16

    If you want to avoid assets or helpers for all controllers, then you can write the following lines in application.rb

    config.generators.stylesheets = false
    config.generators.javascripts = false
    config.generators.helper = false
    

    But if want to avoid for any 1 controller then you generate controller like this

    rails g controller test --no_assets
    rails g controller test --no_helper
    rails g controller test --no_javascripts
    rails g controller test --no_stylesheets
    
    0 讨论(0)
提交回复
热议问题