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

后端 未结 7 1785
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 13:55

    As of Rails 4.2, it's possible to disable route generation with the following code in your application.rb:

    config.generators do |g|
      g.skip_routes  true
    end
    

    Source: https://github.com/rails/rails/commit/4b173b8ed90cb409c1cdfb922914b41b5e212cb6

提交回复
热议问题