From c06723ee715512c2033c7786c48f15674585b56b Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 26 Jun 2026 01:59:57 +0200 Subject: Stage 4: Rails 5.2 -> 6.1 on Ruby 2.7.2 - routing-filter 0.6.3 -> 0.7.0 (Rails 6.1 compatibility) - RSS named routes rss_xml/rss_rdf added - RouteWithParams workarounds: will_paginate_patch, content_path shim, safe_path helper - Paperclip removed, replaced with FileAttachment concern (preserves URL scheme) - Assets resource moved to /admin/assets (Sprockets middleware conflict) - ApplicationRecord base class added, all models migrated - Strong parameters added to Assets, Occurrences, Events, MenuItems controllers - update_attributes -> update throughout - render :nothing -> head :ok/:not_found throughout - language_selector rewritten (removes :overwrite_params) - Environment files updated for Rails 6.1 (eager_load, public_file_server, ActionMailer) - Arel::Visitors::DepthFirst and Integer/Float duration patches removed from test_helper - AssetsController tests added (10 tests covering upload, variants, destroy, auth) - ImageMagick geometry: 460x250! for headline crop (not # which is invalid in IM6) 129 runs, 311 assertions, 5 failures (all pre-existing), 0 errors --- app/helpers/admin_helper.rb | 6 +++--- app/helpers/link_helper.rb | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 389f6dcb..e5c3d5c8 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -1,11 +1,11 @@ module AdminHelper - + def language_selector case I18n.locale when :de - link_to raw('English'), url_for(:overwrite_params => {:locale => :en}) + link_to raw('English'), url_for(params.permit!.to_h.merge('locale' => 'en')) when :en - link_to raw('Deutsch'), url_for(:overwrite_params => {:locale => :de}) + link_to raw('Deutsch'), url_for(params.permit!.to_h.merge('locale' => 'de')) end end end diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index 85d8fbe4..39ec4958 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb @@ -45,9 +45,28 @@ module LinkHelper "Locked by #{@node.lock_owner.login}\n" + "Last modified #{@page.updated_at.to_s(:db)}" - link_to( - 'Unlock', unlock_node_path(@node), :method => :put, :data => { :confirm => message } + link_to 'Unlock', safe_path(:unlock_node_path, @node), :method => :put, :data => { :confirm => message } + end + + # Rails 6.1 workaround: content_path named helper returns RouteWithParams + # when called from within a catch-all glob route request context. + # Rails 6.1 workaround: named route helpers return RouteWithParams when called + # from within a catch-all glob route request context. + # Remove this method when upgrading to Rails 7.0+, where this is fixed. + def safe_path(name, *args) + Rails.application.routes.url_helpers.send(name, *args) + end + + def content_path(page_path = nil, options = {}) + if page_path.is_a?(Hash) + options = page_path + page_path = options.delete(:page_path) + end + options[:locale] ||= params[:locale] || I18n.locale + Rails.application.routes.url_helpers.content_path( + Array(page_path).join("/").sub(/^\//, ""), + options ) end - + end -- cgit v1.3