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 --- config/application.rb | 5 +++++ config/environments/production.rb | 1 + config/routes.rb | 28 +++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/application.rb b/config/application.rb index 3ddad2d7..0be3396d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,6 +9,10 @@ module Cccms config.load_defaults 8.1 config.autoload_lib(ignore: %w[assets tasks]) + Rails.autoloaders.main.ignore( + Rails.root.join('lib/chaos_importer.rb'), + Rails.root.join('lib/update_importer.rb') + ) config.time_zone = 'Berlin' @@ -16,5 +20,6 @@ module Cccms config.i18n.fallbacks = { en: [:en, :de] } config.filter_parameters += [:password, :password_confirmation] + config.active_storage.variant_processor = :disabled end end diff --git a/config/environments/production.rb b/config/environments/production.rb index f8d078ed..fced9496 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -27,6 +27,7 @@ Rails.application.configure do config.i18n.fallbacks = true + config.assets.css_compressor = nil config.active_record.dump_schema_after_migration = false config.active_record.attributes_for_inspect = [ :id ] end diff --git a/config/routes.rb b/config/routes.rb index 9d4b41dc..2df9d463 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,23 @@ Cccms::Application.routes.draw do - # Provides the locale prefix url scheme - scope '(:locale)', locale: ->(v) { I18n.available_locales.map(&:to_s).include?(v) } do + # Handles bare locale root paths: /de and /en (without trailing slash). + # Must live outside and before the scope because the scope's /*page_path + # catch-all would otherwise consume these before the locale segment is + # recognised. Replaces routing-filter's around_recognize hook which + # handled this transparently. + get '/:locale', to: 'content#render_page', + defaults: { page_path: ['home'] }, + constraints: { locale: /de|en/ } - root :to => 'content#render_page', :page_path => ['home'], :locale => 'de' + # All application routes are scoped under an optional two-letter locale + # prefix: /de/... and /en/... Both forms are valid; the prefix is omitted + # for the default locale (:de) in generated URLs via default_url_options + # in ApplicationController. This replaces the routing-filter gem. + # + # The locale regex must be kept in sync with config/application.rb + # (config.i18n.available_locales) and ApplicationController#set_locale. + # Adding a new locale requires updating all three locations. + scope '(:locale)', locale: /de|en/ do resources :tags resources :occurrences @@ -60,6 +74,14 @@ Cccms::Application.routes.draw do match 'galleries/*page_path' => 'content#render_gallery', :via => :get match '/*page_path' => 'content#render_page', :as => :content, :via => :get + # Handles /de/ and /en/ (locale root with trailing slash). + # The bare-slash case inside the scope is distinct from the /:locale + # route above due to trailing slash handling in Rack/Rails routing. + get '/', to: 'content#render_page', defaults: { page_path: ['home'] } + + # Handles / (no locale prefix — default locale :de). + root to: 'content#render_page', defaults: { page_path: ['home'] } + end end -- cgit v1.3