The Most Common Mistakes That Rails Developers Make
Rails is constructed on the principle of convention over configuration. Simply put, this suggests that, by default, Rails assumes that its professional developers can follow “standard” best observe conventions and, if you do, things can work for you “auto-magically” while not your desperate to specify these details. whereas this paradigm has its benefits, , it is also not without its pitfalls.
There are some Common Mistakes That Rails Developers Make:
1. Putting too much logic in the controller:
The problem is that the controller object can begin to violate the one responsibility principle creating future changes to the code base troublesome and fallible. Generally, the only types of logic you must have in your controller are:
- Session and cookie handling
- Model selection
- Request parameter management
2. Putting too much logic in the view
The out-of-the-box Rails templating engine, ERB, may be a good way to create pages with variable content. However, if you’re not careful, you'll be able to presently find yourself with an outsized file that's a combination of hypertext markup language and Ruby code that may be tough to manage and maintain. this is often additionally a locality that may result in numerous repetition, resulting in violations of DRY (don’t repeat yourself) principles.
3. Putting too much logic in the model
Many Rails developers truly build the error and find yourself sticking out everything in their ActiveRecord model categories resulting in Mongolian monetary unit files that not solely violate the only responsibility principle however also are a maintenance nightmare.
The only logic that should remain in your model is:
- Simple mutation methods
- Access wrappers
- Sophisticated queries
4: Ignoring your log files
While most Rails developers are aware of the default log files accessible throughout development and in production, they typically don’t pay enough attention to the knowledge in those files. whereas several applications have faith in log observation tools like Honeybadger or New Relic in production, it's conjointly necessary to stay an eye fixed on your log files throughout the method of developing and testing your application.
5. Using too many gems
Excessive use of gems makes the scale of a Rails method larger than it has to be. this could cut down performance in production. additionally to user frustration, this could additionally lead to the necessity for larger server memory configurations and enlarged in operation prices. It additionally takes longer to begin larger Rails applications, that makes development slower and makes machine-driven tests take longer (and as a rule, slow tests merely don’t get run as often).