From 506cd4bd7ff22d6ab05e4148cd413cec3ee54e68 Mon Sep 17 00:00:00 2001 From: Blair Anderson Date: Sat, 17 Mar 2018 20:50:48 -0700 Subject: [PATCH 1/2] JSON columns do not serialization --- lib/rails-settings.rb | 1 - lib/rails-settings/setting_object.rb | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rails-settings.rb b/lib/rails-settings.rb index ab768535..0aeb0817 100644 --- a/lib/rails-settings.rb +++ b/lib/rails-settings.rb @@ -20,4 +20,3 @@ def self.has_settings(*args, &block) extend RailsSettings::Scopes end end - diff --git a/lib/rails-settings/setting_object.rb b/lib/rails-settings/setting_object.rb index 2397ed18..f8016dc3 100644 --- a/lib/rails-settings/setting_object.rb +++ b/lib/rails-settings/setting_object.rb @@ -13,7 +13,8 @@ class SettingObject < ActiveRecord::Base end end - serialize :value, Hash + + # serialize :value, Hash if RailsSettings.can_protect_attributes? # attr_protected can not be used here because it touches the database which is not connected yet. From 05d1abe096c6808fc17fde340c43f2e57f8a1a42 Mon Sep 17 00:00:00 2001 From: Blair Anderson Date: Mon, 19 Mar 2018 09:31:36 -0700 Subject: [PATCH 2/2] commit this so that peeps on stacks-can-see --- lib/rails-settings/setting_object.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/rails-settings/setting_object.rb b/lib/rails-settings/setting_object.rb index f8016dc3..50a44b13 100644 --- a/lib/rails-settings/setting_object.rb +++ b/lib/rails-settings/setting_object.rb @@ -13,8 +13,9 @@ class SettingObject < ActiveRecord::Base end end - - # serialize :value, Hash + if self.columns_hash['value'].type.to_sym == :text + 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.