Don't generate trash with rails generators
Let’s assume that we have rails >= 3 application. When you generate controller a lot of trash is appeared in your application. I mean here these things: helpers, assets (css and js), view tests. In 99% cases these files are waste and never used, so it’s reasonable to disable generating their. It’s very easy.
Configure your application
Go to config/application.rb and paste there these lines:
These magic lines of code will get rid of headache and you will forget about removing these trash manually forever!
Also I recommend to don’t pass action names in rails controller generator because it inserts automatically routes which always are changed later.
Say we have runned command
rails g controller users new edit it will generate the following trash.
Example of generated routes:
It also generates tests which are never remained in this look. For my opinion it’s more useful to have pending tests than tests which do nothing.
Example of generated tests for controller:
Thank you for your attention!
WideFix and Ruby On Rails expertise
At WideFix, we take pride in our expertise and experience. You can trust that our solutions will not harm your business and will always keep your site running smoothly. You can rely on us to provide confident and effective solutions that meet your needs.