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 assets for every controller, I put following codes into config/application.rb
:
config.generators do |g| g.helper false g.assets false end
There is another thing I don't want to happen. The generator adds a line get "foo/index"
to my config/routes.rb
. How can I prevent it?
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
This is counter intuitive, but here it is what you're looking for:
config.generators do |g|
g.skip_routes true
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With