From f2613aa5aed5eb2091df8c6fb82aee9c811dea01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 1 Aug 2022 17:14:22 +0200 Subject: [PATCH] Allow symbols in YAML columns Without this change, we were getting errors when manually creating an annotation using symbols in the ranges hash (that is, `ranges: [{ start: "/p[1] }]` instead of `ranges: [{ "start" => "/p[1] }]`. Using symbols isn't really supported and it might cause strange issues with code like: `@draft_version.annotations.find_by(range_start: ...)`. However, this might be an extreme case and using symbols might work properly most of the time (if not all the time), and we've been using them in our demo for years. So I'm not writing a test for this case because I'm not sure we should support it, but I'm still allowing symbols so we don't get exceptions in cases where everything might be working fine. Rails already adds Symbol by default to column permitted classes [1], so it's safe to enable it. [1] https://github.com/rails/rails/pull/45584/commits/c2b96e3e8 --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 731fce0a2..a0de876cb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,7 +22,7 @@ module Consul config.active_support.use_authenticated_message_encryption = false # Keep reading existing data in the legislation_annotations ranges column - config.active_record.yaml_column_permitted_classes = [ActiveSupport::HashWithIndifferentAccess] + config.active_record.yaml_column_permitted_classes = [ActiveSupport::HashWithIndifferentAccess, Symbol] # Handle custom exceptions config.action_dispatch.rescue_responses["FeatureFlags::FeatureDisabled"] = :forbidden