This is a robust approach to making controller/{conference_name}/* case insensitive. Richard reported this issue in regards to West2026 flyer.

This commit is contained in:
2026-03-15 08:47:42 +00:00
parent dc9665b79d
commit 69e8a29fc7
5 changed files with 16 additions and 6 deletions
+6
View File
@@ -0,0 +1,6 @@
class SlugConstraint
def matches?(request)
request.params[:slug] = request.params[:slug].downcase if request.params[:slug]
true
end
end
+5 -1
View File
@@ -3,6 +3,10 @@ Sidekiq::Web.set :sessions, false
BikeBike::Application.routes.draw do
# Redirect uppercase CONFERENCES to lowercase conferences
get '/CONFERENCES(*anything)', to: redirect { |params, request| "/conferences#{params[:anything]}" }
get '/CONFERENCES', to: redirect('/conferences')
# Conferences
scope :conferences do
root 'conferences#list', as: :conferences
@@ -10,7 +14,7 @@ BikeBike::Application.routes.draw do
get 'new' => 'administration#new', as: :new_conference
post 'save' => 'administration#save', as: :save_conference
scope ':slug', constraints: { slug: /[^\/]+/ } do
scope ':slug', constraints: SlugConstraint.new do
root 'conferences#view', as: :conference
get 'edit' => 'administration#edit', as: :edit_conference