From f3f6fe74f047817a9ff8aa9bdaffee34bcf588d4 Mon Sep 17 00:00:00 2001 From: Richard Towers Date: Wed, 6 Nov 2024 11:09:37 +0000 Subject: [PATCH] WIP fix ordering of attributes --- app/models/concerns/image_kind.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/image_kind.rb b/app/models/concerns/image_kind.rb index fdc046dd49f..1a482b59e05 100644 --- a/app/models/concerns/image_kind.rb +++ b/app/models/concerns/image_kind.rb @@ -5,14 +5,17 @@ module ImageKind def assign_attributes(attributes) # It's important that the image_kind attribute is assigned first, as it is intended to be used by # carrierwave uploaders when they are mounted to work out which image versions to use. - image_kind_attributes = attributes.slice(:image_kind) - attributes.reverse_merge!(image_kind_attributes) unless image_kind_attributes.empty? - - super + image_kind = attributes.delete(:image_kind) + ordered_attributes = if image_kind.present? + { image_kind:, **attributes } + else + attributes + end + super ordered_attributes end def image_kind - attributes.fetch(:image_kind, "default") + attributes.fetch("image_kind", "default") end def image_kind_config