summaryrefslogtreecommitdiff
path: root/app/helpers/link_helper.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-26 01:59:57 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-26 01:59:57 +0200
commitc06723ee715512c2033c7786c48f15674585b56b (patch)
tree46d074bde9a4fc61f0a76cbc601007ed4412ec61 /app/helpers/link_helper.rb
parent0818a3057b0a91e422158d828026c941b4e10622 (diff)
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
Diffstat (limited to 'app/helpers/link_helper.rb')
-rw-r--r--app/helpers/link_helper.rb25
1 files changed, 22 insertions, 3 deletions
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb
index 85d8fbe..39ec495 100644
--- a/app/helpers/link_helper.rb
+++ b/app/helpers/link_helper.rb
@@ -45,9 +45,28 @@ module LinkHelper
45 "Locked by #{@node.lock_owner.login}\n" + 45 "Locked by #{@node.lock_owner.login}\n" +
46 "Last modified #{@page.updated_at.to_s(:db)}" 46 "Last modified #{@page.updated_at.to_s(:db)}"
47 47
48 link_to( 48 link_to 'Unlock', safe_path(:unlock_node_path, @node), :method => :put, :data => { :confirm => message }
49 'Unlock', unlock_node_path(@node), :method => :put, :data => { :confirm => message } 49 end
50
51 # Rails 6.1 workaround: content_path named helper returns RouteWithParams
52 # when called from within a catch-all glob route request context.
53 # Rails 6.1 workaround: named route helpers return RouteWithParams when called
54 # from within a catch-all glob route request context.
55 # Remove this method when upgrading to Rails 7.0+, where this is fixed.
56 def safe_path(name, *args)
57 Rails.application.routes.url_helpers.send(name, *args)
58 end
59
60 def content_path(page_path = nil, options = {})
61 if page_path.is_a?(Hash)
62 options = page_path
63 page_path = options.delete(:page_path)
64 end
65 options[:locale] ||= params[:locale] || I18n.locale
66 Rails.application.routes.url_helpers.content_path(
67 Array(page_path).join("/").sub(/^\//, ""),
68 options
50 ) 69 )
51 end 70 end
52 71
53end 72end