rails/rails — pull request #8313 by alan (2012-11-25 21:52:41+00:00)
Title: Save has_one associations only if record has changes

Prevents save related callbacks such as `after_commit` being triggered when has_one objects are already persisted and have no changes.

Recently I found that `after_commit` callbacks were being triggered by the `autosave` behaviour on has_one records that had no changes.

For example, using the tests terminology, if a pirate has one ship, when the pirate is saved (with autosave enabled) then `after_commit` callbacks on ship are being triggered. I assume that other save
related callbacks are also being triggered which might be undesirable.

The same problem was fixed for belongs_to records in rails@658bb4f for an old lightouse ticket - https://rails.lighthouseapp.com/projects/8994/tickets/3353