I have two scaffold-generated models: Book and Bookbag. A Bookbag has-many Books, and a Book belongs-to a Bookbag. Each Book has a weight, and each Bookbag has an average-weight that is supposed to store the average weight of all of its Books. What is the best way to keep average-weight up to date?
Using a before-save filter on Bookbag doesn't work because it's not called on every update to a Book it contains, and I don't want to update average-weight on every Book update, only when a Book's weight changes.