From 3eeca62dfcbf10c36d6758e2b95bff968e4a59d8 Mon Sep 17 00:00:00 2001 From: "jonathan.kerr" <3410350+jonodrew@users.noreply.github.com> Date: Tue, 10 Mar 2026 20:52:10 +0000 Subject: [PATCH] Update the default method when rendering a 404 This was a very strange bug. We found that users visiting `events/introduction-to-git-1/invitation/hello@codebar.io` (we don't know how this url was generated) caused the application to crash. We fixed it with 6c83d9287c9885d66847bbd06cd242328c25e121, but it bothered me that the 404 page was not our standard one. It turns out that rails interprets a dot as a format separator. That meant the url was being parsed as `events/introduction-to-git-1/invitation/hello@codebar.`, with a format of 'io'. In our previous application_controller.rb file, that was caught by the line ` format.all { head :not_found }`. The result of this should be a nice splash page whenever there's a 404, including where a URL is malformed. Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com> --- app/controllers/application_controller.rb | 5 +---- app/controllers/invitations_controller.rb | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6994aa17d..e11faaab7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -30,10 +30,7 @@ class ApplicationController < ActionController::Base before_action :accept_terms, if: :logged_in? def render_not_found - respond_to do |format| - format.html { render template: 'errors/not_found', layout: false, status: :not_found } - format.all { head :not_found } - end + render template: 'errors/not_found', layout: false, status: :not_found end protected diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index 89ec7788b..3fc838849 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -87,8 +87,7 @@ def cancel_meeting private def set_invitation - @invitation = Invitation.find_by(token: params[:token]) - raise ActionController::RoutingError, 'Invitation not found' unless @invitation + @invitation = Invitation.find_by!(token: params[:token]) end def load_invitation