From 1f5d1daaa8b4366a37e54a662d1b79718877eec7 Mon Sep 17 00:00:00 2001 From: Mikkel Malmberg Date: Fri, 22 Sep 2023 10:08:03 +0200 Subject: [PATCH] Fix serialize type deprecation warning on Rails 7.1+ (#113) --- lib/rails-settings/setting_object.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rails-settings/setting_object.rb b/lib/rails-settings/setting_object.rb index 5f60f30..a0f3dc0 100644 --- a/lib/rails-settings/setting_object.rb +++ b/lib/rails-settings/setting_object.rb @@ -13,7 +13,11 @@ class SettingObject < ActiveRecord::Base end end - serialize :value, Hash + if ActiveRecord.version >= Gem::Version.new("7.1.0.beta1") + serialize :value, type: Hash + else + serialize :value, Hash + end if RailsSettings.can_protect_attributes? # attr_protected can not be used here because it touches the database which is not connected yet.