From cf1cdf7e7db2c08e1abc8ba767bd160e55c08973 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sat, 24 Feb 2024 15:22:14 -0800 Subject: [PATCH] Reorder the higher-up lines of SwfAsset A lot of stuff was mixed together, including methods interrupting the scopes and relationships, oops! Fixed! --- app/models/swf_asset.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index 38e62fad..a3bbf675 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -8,6 +8,9 @@ class SwfAsset < ApplicationRecord # We use the `type` column to mean something other than what Rails means! self.inheritance_column = nil + # Used in `item_is_body_specific?`. (TODO: Could we refactor this out?) + attr_accessor :item + IMAGE_SIZES = { :small => [150, 150], :medium => [300, 300], @@ -16,9 +19,16 @@ class SwfAsset < ApplicationRecord belongs_to :zone has_many :parent_swf_asset_relationships + has_one :contribution, :as => :contributed, :inverse_of => :contributed + has_many :parent_swf_asset_relationships before_validation :normalize_manifest_url, if: :manifest_url? + delegate :depth, :to => :zone + + scope :biology_assets, -> { where(:type => PetState::SwfAssetType) } + scope :object_assets, -> { where(:type => Item::SwfAssetType) } + PARTITION_COUNT = 3 PARTITION_DIGITS = 3 PARTITION_ID_LENGTH = PARTITION_COUNT * PARTITION_DIGITS @@ -42,16 +52,6 @@ class SwfAsset < ApplicationRecord "#{image_version}" end - attr_accessor :item - - has_one :contribution, :as => :contributed, :inverse_of => :contributed - has_many :parent_swf_asset_relationships - - delegate :depth, :to => :zone - - scope :biology_assets, -> { where(:type => PetState::SwfAssetType) } - scope :object_assets, -> { where(:type => Item::SwfAssetType) } - # To manually change the body ID without triggering the usual change to 0, # use this override method. def override_body_id(new_body_id)