DEV Community

Discussion on: Ruby On Rails Best Practice 2020 (for us)

Collapse
 
simonini profile image
Alessandro

Yes :-)

Collapse
 
pepetorres1998 profile image
Jose Antonio Torres Garibay

And in example, where I work we have an after_update on a model that is a Transaction and it checks if the updated attribute is status and if it is then recalculate the PromissoryNote attached to that Transaction (is a simplified example), without using that hook where can you put that logic?

Thread Thread
 
simonini profile image
Alessandro

Normally we work on controller and put it inside an interaction (github.com/AaronLasseigne/active_i...) or service object. The solution some times is more verbose but the developer regain control. When you are developing a prototype can be a good idea use "callback and friends" to go faster but when things get complicated we try to avoid it. This rule is not a strict rule but a suggestion to avoid "callback hell"

Thread Thread
 
pepetorres1998 profile image
Jose Antonio Torres Garibay

Thanks man! I'd seriously take this in consideration, we might be in callback hell already 😅