impress/app/models/parent_swf_asset_relationship.rb

27 lines
525 B
Ruby
Raw Permalink Normal View History

class ParentSwfAssetRelationship < ApplicationRecord
2023-07-22 12:36:04 -07:00
self.table_name = 'parents_swf_assets'
belongs_to :parent, :polymorphic => true
2011-01-27 13:35:46 -08:00
belongs_to :swf_asset
after_save :update_parent_cached_fields
after_destroy :update_parent_cached_fields
def item=(replacement)
self.parent = replacement
2010-05-16 17:45:30 -07:00
end
def pet_state
2011-01-27 13:35:46 -08:00
PetState.find(parent_id)
2010-05-16 17:45:30 -07:00
end
def pet_state=(replacement)
self.parent = replacement
end
def update_parent_cached_fields
parent.try(:update_cached_fields)
end
end