From a1ddc25da0d2aa79a4d9216ef7792f26233bd38e Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 26 Jun 2026 05:19:28 +0200 Subject: Stage 5 fixes: RouteWithParams removal, Globalize fallbacks, search stub, to_s(:db) → to_fs(:db), LockedByAnotherUser autoload, test environment config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove safe_path helper and content_path shim from link_helper.rb - Update all safe_path call sites in views to use named route helpers directly - Fix Globalize fallbacks via config.i18n.fallbacks in application.rb, remove i18n initializer - Stub Node.search returning none (search disabled pending PostgreSQL upgrade) - Replace to_s(:db) with to_fs(:db) in node.rb, nodes_helper.rb, link_helper.rb, admin view - Move LockedByAnotherUser to app/models/locked_by_another_user.rb for Zeitwerk autoloading - Fix config/environments/test.rb: config.assets removed, cache_classes → enable_reloading, test_order removed, minitest pinned to ~> 5.25 - Fix config/environments/development.rb: cache_classes → enable_reloading - Park search vector migration in doc/ pending PostgreSQL and plpgsql availability --- app/helpers/link_helper.rb | 35 ++++++-------------------------- app/helpers/nodes_helper.rb | 2 +- app/models/locked_by_another_user.rb | 1 + app/models/node.rb | 13 +++++++----- app/views/admin/_recent_changes.html.erb | 2 +- app/views/content/_search.html.erb | 2 +- app/views/content/_tags.html.erb | 2 +- app/views/layouts/application.html.erb | 4 ++-- 8 files changed, 21 insertions(+), 40 deletions(-) create mode 100644 app/models/locked_by_another_user.rb (limited to 'app') diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index 39ec495..cb13c8d 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb @@ -1,5 +1,5 @@ module LinkHelper - + def content_path_helper path_array url_for( :controller => :content, @@ -8,11 +8,11 @@ module LinkHelper :page_path => path_array ) end - + def content_url_helper path_array request.protocol + request.host_with_port + content_path_helper(path_array) end - + def link_to_path title, path, html_options = {} return "" if path.nil? @@ -22,9 +22,7 @@ module LinkHelper end active_class = active ? {:class => 'active'} : {:class => 'inactive'} - html_options = html_options.merge(active_class) - locale = params[:locale] || I18n.locale link_to( @@ -39,34 +37,13 @@ module LinkHelper return :class => "selected" end end - + def unlock_link message = "Are you sure you want to unlock?\n" + "Locked by #{@node.lock_owner.login}\n" + - "Last modified #{@page.updated_at.to_s(:db)}" - - 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 + "Last modified #{@page.updated_at.to_fs(:db)}" - 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 - ) + link_to 'Unlock', unlock_node_path(@node), :method => :put, :data => { :confirm => message } end end diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb index 204ad8a..c739ccd 100644 --- a/app/helpers/nodes_helper.rb +++ b/app/helpers/nodes_helper.rb @@ -31,7 +31,7 @@ module NodesHelper def event_information if @node.event - "#{@node.event.start_time.to_s(:db)} - #{@node.event.end_time.to_s(:db)} > " \ + "#{@node.event.start_time.to_fs(:db)} - #{@node.event.end_time.to_fs(:db)} > " \ "#{link_to 'show', event_path(@node.event)} " \ "#{link_to 'edit', edit_event_path(@node.event)}" else diff --git a/app/models/locked_by_another_user.rb b/app/models/locked_by_another_user.rb new file mode 100644 index 0000000..6f9e272 --- /dev/null +++ b/app/models/locked_by_another_user.rb @@ -0,0 +1 @@ +class LockedByAnotherUser < StandardError; end diff --git a/app/models/node.rb b/app/models/node.rb index f7a70d0..41c3867 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -73,7 +73,7 @@ class Node < ApplicationRecord raise( LockedByAnotherUser, "Page is locked by another user who is working on it! " \ - "Last modification: #{draft.updated_at.to_s(:db)}" + "Last modification: #{draft.updated_at.to_fs(:db)}" ) else lock_for! current_user @@ -211,6 +211,13 @@ class Node < ApplicationRecord self.created_at < new_id_format_date ? unique_path : id end + # TODO: restore full-text search once PostgreSQL is upgraded. + # The tsvector/plpgsql approach requires PostgreSQL 10+ with plpgsql available. + # For now, search is disabled to unblock the Rails 7.2 upgrade. + def self.search(term, _ = {}) + none + end + protected def lock_for! current_user self.lock_owner = current_user @@ -255,7 +262,3 @@ class Node < ApplicationRecord end end end - -class LockedByAnotherUser < StandardError; end - - diff --git a/app/views/admin/_recent_changes.html.erb b/app/views/admin/_recent_changes.html.erb index 300d088..88b5e93 100644 --- a/app/views/admin/_recent_changes.html.erb +++ b/app/views/admin/_recent_changes.html.erb @@ -13,7 +13,7 @@ <%= truncated_title_for_node node %> <%= node.unique_name %> <%= node.draft.user.login rescue "" %> - <%= node.updated_at.to_s(:db) %> + <%= node.updated_at.to_fs(:db) %> <%= link_to 'Show', node_path(node) %> <%= link_to "Revisions", revision_path(:id => node.id) %> diff --git a/app/views/content/_search.html.erb b/app/views/content/_search.html.erb index f732fca..aa91424 100644 --- a/app/views/content/_search.html.erb +++ b/app/views/content/_search.html.erb @@ -1,3 +1,3 @@ -<%= form_tag safe_path(:search_path), :method => 'get' do %> +<%= form_tag search_path, :method => 'get' do %>
<%= text_field_tag :search_term, params[:search_term], :placeholder => 'suchen', :type => 'search' %>
<% end %> diff --git a/app/views/content/_tags.html.erb b/app/views/content/_tags.html.erb index 387f51c..f0e7210 100644 --- a/app/views/content/_tags.html.erb +++ b/app/views/content/_tags.html.erb @@ -3,7 +3,7 @@

Tags

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 84dcdc6..c5cbf14 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -52,8 +52,8 @@ <% end %> -- cgit v1.3