Created
December 4, 2017 20:16
-
-
Save ornerymoose/72bf96ad2cfff54a3fb91c902036bf1d to your computer and use it in GitHub Desktop.
So this 'works', in a sense: it's doing the UPDATE but also doing an INSERT. Why is that? Screenshot of server log: https://imgur.com/a/8FCPN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Relationship < ApplicationRecord | |
belongs_to :outage | |
belongs_to :child | |
validate :outage_changed, if: :outage_id_changed? | |
private | |
def outage_changed | |
Relationship.where(child_id: self.child_id).update_all(outage_id: self.outage_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment