From 4c22631a5a85b3082f0525cc2454d2bd2251922a Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 27 Jun 2026 20:28:00 +0200 Subject: Fix routes after removing the routing-filter --- app/helpers/link_helper.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index ea6c26f..878e8e4 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb @@ -4,7 +4,7 @@ module LinkHelper url_for( :controller => :content, :action => :render_page, - :locale => params[:locale] || I18n.locale, + :locale => (params[:locale] || I18n.locale).to_sym == I18n.default_locale ? nil : (params[:locale] || I18n.locale), :page_path => path_array ) end @@ -23,7 +23,7 @@ module LinkHelper active_class = active ? {:class => 'active'} : {:class => 'inactive'} html_options = html_options.merge(active_class) - locale = params[:locale] || I18n.locale + locale = (params[:locale] || I18n.locale).to_sym == I18n.default_locale ? nil : (params[:locale] || I18n.locale) link_to( title, @@ -46,4 +46,17 @@ module LinkHelper method: :put, form: { data: { confirm: message } } end + + def content_path(page_path = nil, options = {}) + if page_path.is_a?(Hash) + options = page_path + page_path = options.delete(:page_path) + end + locale = options[:locale] || params[:locale] || I18n.locale + options[:locale] = (locale.to_sym == I18n.default_locale) ? nil : locale + Rails.application.routes.url_helpers.content_path( + Array(page_path).join("/").sub(/^\//, ""), + options + ) + end end -- cgit v1.3