From 310a0e1187f76dae1641b2b2b1c3bb4959494569 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Mon, 14 Oct 2019 13:52:44 -0500 Subject: [PATCH] Support back link on non resource links --- app/helpers/dunlop/application_helper.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/helpers/dunlop/application_helper.rb b/app/helpers/dunlop/application_helper.rb index e53e235..465c506 100644 --- a/app/helpers/dunlop/application_helper.rb +++ b/app/helpers/dunlop/application_helper.rb @@ -109,7 +109,21 @@ module Dunlop end def page_title_for_string(args) - args.first + title = args.first + options = args.last.is_a?(Hash) ? args.last : {} + if back_options = options[:back] + url = + case back_options + when Array then polymorphic_path(back_options) + when true then :back + else back_options + end + if url + back_link = link_to content_tag(:i, nil, class: 'left arrow icon'), url, class: 'title-back-link' + title = [back_link, title].join.html_safe + end + end + title end def page_title_for_resource(args)