From ae823409ab35f33b047bc65bce912cd8689ab31b Mon Sep 17 00:00:00 2001 From: Iris Lau Date: Tue, 24 Oct 2023 15:14:06 +0100 Subject: [PATCH] WIP --- app/models/featured_image_data.rb | 4 ++++ app/models/organisation.rb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/featured_image_data.rb b/app/models/featured_image_data.rb index 7773038a6d1..f7b6420f9b4 100644 --- a/app/models/featured_image_data.rb +++ b/app/models/featured_image_data.rb @@ -4,6 +4,10 @@ class FeaturedImageData < ApplicationRecord validates :file, presence: true, if: :image_changed? validates_with ImageValidator, size: [960, 640], if: :image_changed? + has_many :assets, + as: :assetable, + inverse_of: :assetable + private def image_changed? diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 11318f47909..f40d52f4cc2 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -10,8 +10,8 @@ class Organisation < ApplicationRecord DEFAULT_JOBS_URL = "https://www.civilservicejobs.service.gov.uk/csr".freeze FEATURED_DOCUMENTS_DISPLAY_LIMIT = 6 - belongs_to :default_news_image_legacy, class_name: "DefaultNewsOrganisationImageData", foreign_key: :default_news_organisation_image_data_id - belongs_to :default_news_image, class_name: "FeaturedImageData", foreign_key: :featured_image_data_id + belongs_to :default_news_image, class_name: "DefaultNewsOrganisationImageData", foreign_key: :default_news_organisation_image_data_id + belongs_to :default_news_image_new, class_name: "FeaturedImageData", foreign_key: :featured_image_data_id has_many :assets, as: :assetable,