From 2744362dc70eac3a9b8007bac2ecf8f423c72409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Tue, 12 Jan 2021 11:24:38 +0100 Subject: [PATCH] Extract method to get the text of the section link So we can override it when using inheritance. --- app/components/sdg_management/subnavigation_component.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/components/sdg_management/subnavigation_component.rb b/app/components/sdg_management/subnavigation_component.rb index 41096a618..5a497f28b 100644 --- a/app/components/sdg_management/subnavigation_component.rb +++ b/app/components/sdg_management/subnavigation_component.rb @@ -12,9 +12,11 @@ class SDGManagement::SubnavigationComponent < ApplicationComponent end def link_to_section(section) - link_to "SDG::#{section.to_s.classify}".constantize.model_name.human(count: 2).titleize, - path_for(section), - class: active_style(section) + link_to text_for(section), path_for(section), class: active_style(section) + end + + def text_for(section) + "SDG::#{section.to_s.classify}".constantize.model_name.human(count: 2).titleize end def path_for(section)