3 ms·
A rails veteran that still heavily relies on ActiveRecord's callbacks sounds a bit weird to me...
by apeacox 9y ago
A rails veteran that still heavily relies on ActiveRecord's callbacks sounds a bit weird to me...
- cageface 9y agoWhat would you use instead?
- apeacox 9y agoCommands (or Service Objects) are a better approach. Isolating business logic and actions let you keep the control of what's going on.
- Lockyy 9y agoDo you have any resources to expand on the issues with AR callbacks? I'm interested to read up on this.
- apeacox 9y agoIn short: you lose control of what is happening, especially when you expand/inherit other classes. These kind of problems arise after few months of development, when the codebase is grown enough and starts becoming even more difficult to change or extend. Try to check Trailblazer for a different approach.
- jmcgough 9y agoAR callbacks can also make it harder to write tests.
- Exuma 9y agoYeah... that immediately was a red flag for inexperience. Not to mention when hes "not sure" if things were cleaned up. How have you been programming for 10 years and don't know how to properly clean up records, whether its through the database, ORM, or manually in a transaction. It sounds like this guy has sucked on the rails teet for far too long, instead of challenging himself with other approaches and paradigms.