wide-waiter-22763
07/08/2026, 5:15 AMabsence.update, or just call some kind of "Service" all together, which handles the update and all side effects. However, with Avo, I'm not writing the controller myself - and as far as I can tell from the documentation, I can only set some redirect paths and similar in the controllers.
One way to solve this would be callbacks in my model, a before_update :update_absence_days. This works, however, I generally try to avoid callbacks, as they are hard to reason about, especially in large applications, and they make testing harder, especially when creating records with FactoryBot
Another way I found are actions, where I can mimic the editable fields and then do all of my logic inside the def handle method. That works well, and I can disable the regular edit with authorization. However, it is rather verbose to add an action for each of the modifying CRUD operations (to be fair, I currently only need these side effects for very few ressources, but that might change).
Are there any other ways to handle these kinds of side effects that I'm missing? Did you maybe think about this topic and came to something like a "suggested solution"? Thanks for any input! 🙂miniature-optician-85831
07/08/2026, 5:16 AMloud-jewelry-99127
07/08/2026, 5:18 AMloud-jewelry-99127
07/08/2026, 5:18 AMloud-jewelry-99127
07/08/2026, 5:19 AMloud-jewelry-99127
07/08/2026, 5:21 AMloud-jewelry-99127
07/08/2026, 5:23 AMwide-waiter-22763
07/08/2026, 5:25 AMdef save_record_action, and instead of implementing this with @record.save!, I could add my side-effects there? That would indeed help a lot, I think! However, those methods are all private - wouldn't they need to be protected in order to be overwritable? (Not quite sure with Ruby, as this is very lax with these things. I can try it out later 🙂 )loud-jewelry-99127
07/08/2026, 5:30 AMwide-waiter-22763
07/08/2026, 6:51 AMdef save_record_action
@record.transaction do
@record.update_absence_days
@record.save
end
end
Might be worth a hint in the docs, together with keywords like side-effects, callbacks or similar 😄 Thanks for your help!loud-jewelry-99127
07/08/2026, 6:53 AMloud-jewelry-99127
07/08/2026, 6:53 AM