From e2fd841310f342acd39bcb981c104053ed8bfcbd Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 24 Feb 2023 09:20:45 +0100 Subject: [PATCH] Use the newer `serialize` signature if available On 7.1 serialize properly split `coder` and `type` arguments instead of taking a single positional argument and try to figure out which is which. While we're at it, we can explictly define we're using YAML here instead of relying on the default that is now configurable. --- app/models/maintenance_tasks/run.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/maintenance_tasks/run.rb b/app/models/maintenance_tasks/run.rb index 600b2f5d..f711e086 100644 --- a/app/models/maintenance_tasks/run.rb +++ b/app/models/maintenance_tasks/run.rb @@ -46,8 +46,13 @@ class Run < ApplicationRecord attr_readonly :task_name - serialize :backtrace - serialize :arguments, JSON + if Rails.gem_version >= Gem::Version.new("7.1.alpha") + serialize :backtrace, coder: YAML + serialize :arguments, coder: JSON + else + serialize :backtrace + serialize :arguments, JSON + end scope :active, -> { where(status: ACTIVE_STATUSES) } scope :completed, -> { where(status: COMPLETED_STATUSES) }