Software engineering and personal development

Tag: model

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

Rename Rails controllers, views and migrations with Rails Refactor

Img source: https://www.youtube.com/watch?v=-sX05s0STs8

There can be cases where you wished you named that controller a lot better, as it does not make any sense and is very ambiguous in its current form. If you have ever wondered whether there is a way for you to do quick renamings of multiple related files inside a Rails project, then I have some good news for you. There is already a gem called Rails Refactor, that can be used to do these renamings. Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑