Software engineering and personal development

Month: March 2018

Get previous values of model attributes in Rails using a pre-existing helper

Img source: binarywebpark.com

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.

Continue reading

Find out which gems are consuming the most of your memory with Derailed

Img source: blog.honeybadger.io

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.

Continue reading

How to write complex queries using Globalize gem in Rails applications

Img source: railscarma.com

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.

Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑