If you want to keep your code maintainable, secure, and optimized, look at some gems for code optimization and cleanup
suggest changeThis one particularly blew my mind. The bullet gem helps you kill all the N+1 queries, as well as unnecessarily eager loaded relations. Once you install it and start visiting routes in development, alert boxes warn about database queries that need to be optimized. It works right out of the box and is extremely helpful for optimizing your application.
Static code analyzer for finding Rails specific code smells. It offers a variety of suggestions; use scope access, restrict auto-generated routes, add database indexes, etc. It also has many suggestions that show how to refactor the code and where Rails conventions are being missed.
RuboCop is a Ruby static analyzer that checks code against community style guidelines. It reports violations on the command line, including useless assignment, redundant Object#to_s in interpolation, and unused method arguments.
A good thing is that it’s highly configurable, since the analyzer can be quite irritating if you’re not following the Ruby style guide 100% (i.e. you have lots of trailing whitespaces or you double quote your strings even when not interpolating, etc.).
Cops are grouped into departments. This era of the gem centered on Style, Lint, Metrics, and Rails. Later versions add more departments.