When updating/inserting a model (namely
note) I need Phoenix to update
updated_at field of the related model (
notepad). There is a ∞:1 relationship between
I’ve came up with a solution to touch the
notepad or simply set its
updated_at field to the current datetime, but this seems like a dirty hack, thus I’m looking for a more elegant solution.
I would go explicit, like what you have right now. Don’t rely on hidden black-boxes or methods with side-effects because it hurts long-term productivity.
In your method when you update a note, call a method named
Explicit is good
Thanks. That’s what I’ll do (:
This may be relevant:
You can pass a force: true option when you call Repo.update with an empty changeset and that should be enough.