From 85f13f95012458c958d4e69a058d039838d24c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 20 May 2021 18:14:26 +0200 Subject: [PATCH] Use namespace as symbol in polymorphic_path calls Our `namespace` helper returns a string. However, Rails version 5.2.4.6 doesn't allow strings as arguments to polymorphic_path [1] Since returning a symbol in our `namespace` helper would break other places in the application, we're converting it to a symbol in the methods calling `polymorphic_path`. [1] https://github.com/advisories/GHSA-hjg4-8q5f-x6fm --- app/views/admin/widget/cards/_form.html.erb | 2 +- config/initializers/routes_hierarchy.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb index 1faf4c3ee..37676354b 100644 --- a/app/views/admin/widget/cards/_form.html.erb +++ b/app/views/admin/widget/cards/_form.html.erb @@ -1,6 +1,6 @@ <%= render "shared/globalize_locales", resource: card %> -<%= translatable_form_for [namespace, card.cardable, card], url: local_assigns[:url] do |f| %> +<%= translatable_form_for [namespace.to_sym, card.cardable, card], url: local_assigns[:url] do |f| %> <%= render "shared/errors", resource: card %>
diff --git a/config/initializers/routes_hierarchy.rb b/config/initializers/routes_hierarchy.rb index 9b5cded6f..7fda048ff 100644 --- a/config/initializers/routes_hierarchy.rb +++ b/config/initializers/routes_hierarchy.rb @@ -30,9 +30,9 @@ module ActionDispatch::Routing::UrlFor resolve = resolve_for(resource) resolve_options = resolve.pop - polymorphic_path([namespace, *resolve], options.merge(resolve_options)) + polymorphic_path([namespace.to_sym, *resolve], options.merge(resolve_options)) else - polymorphic_path([namespace, *resource_hierarchy_for(resource)], options) + polymorphic_path([namespace.to_sym, *resource_hierarchy_for(resource)], options) end end