One of the best practices is keeping your controllers with as little code as possible, and have all the validations in the models. Rails includes a lot of validations that you can use in your models, and many other helpers that help you focus on your business logic and develop your projects as quickly as possible. A helper method that is among the unpopular ones is the possibility to check the old value of an attribute of a object, before doing any database transaction.
Month: March 2018
One of the best JavaScript libraries for working with dates is moment. It is really easy to install, use and has many functions that help you with parsing, validating, manipulating and formatting dates.
Rails gives you a lot of great ways for rapid development, but there comes a time when your application is already mature and needs to be optimized, because it has become slow. The more gems you add to it, the slower it tends to get. Each gem you add in your project will increase the level of RAM this app consumes. Here is a gem called derailed that can help you learn about other gems, developed by Richard Schneeman.
Globalize is one of the most famous gems that is used for translating dynamic content in Rails application. It is really easy to use, and brings a lot of conveniences immediately after you add it in your application. I recently had to do a more complex query using the table added by Globalize generator, and I could not find that much information about ways of doing joins for this newly added table with the one that it corresponds and that translates its attributes. In this article, you can see a short example on how to do that.