Emi Matchu
e3d196fe87
Because we ended up with such a big error, and it doesn't have an easy fix, I'm wrapping up today by reverting the entire set of refactors we've done lately, so modeling in production can continue while we improve this code further over time. I generated this commit by hand-picking the refactor-y commits recently, running `git revert --no-commit <hash>` in reverse order, then manually updating `pet_spec.rb` to reflect the state of the code: passing the most important behavioral tests, but no longer passing one of the kinds of annoyances I *did* fix in the new code. ```shell git revert --no-commit48c1a58df9
git revert --no-commit42e7eabdd8
git revert --no-commitd82c7f817a
git revert --no-commit5264947608
git revert --no-commit90407403ba
git revert --no-commit242b85470d
git revert --no-commit9eaee4a2d4
git revert --no-commit52ca41dbff
git revert --no-commitc03e7446e3
git revert --no-commitf81415d327
git revert --no-commit13ceec8fcc
```
26 lines
525 B
Ruby
26 lines
525 B
Ruby
class ParentSwfAssetRelationship < ApplicationRecord
|
|
self.table_name = 'parents_swf_assets'
|
|
|
|
belongs_to :parent, :polymorphic => true
|
|
|
|
belongs_to :swf_asset
|
|
|
|
after_save :update_parent_cached_fields
|
|
after_destroy :update_parent_cached_fields
|
|
|
|
def item=(replacement)
|
|
self.parent = replacement
|
|
end
|
|
|
|
def pet_state
|
|
PetState.find(parent_id)
|
|
end
|
|
|
|
def pet_state=(replacement)
|
|
self.parent = replacement
|
|
end
|
|
|
|
def update_parent_cached_fields
|
|
parent.try(:update_cached_fields)
|
|
end
|
|
end
|