Skip to content

Commit 3eeca62

Browse files
committed
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 6c83d92, 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>
1 parent 972c892 commit 3eeca62

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

app/controllers/application_controller.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ class ApplicationController < ActionController::Base
3030
before_action :accept_terms, if: :logged_in?
3131

3232
def render_not_found
33-
respond_to do |format|
34-
format.html { render template: 'errors/not_found', layout: false, status: :not_found }
35-
format.all { head :not_found }
36-
end
33+
render template: 'errors/not_found', layout: false, status: :not_found
3734
end
3835

3936
protected

app/controllers/invitations_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ def cancel_meeting
8787
private
8888

8989
def set_invitation
90-
@invitation = Invitation.find_by(token: params[:token])
91-
raise ActionController::RoutingError, 'Invitation not found' unless @invitation
90+
@invitation = Invitation.find_by!(token: params[:token])
9291
end
9392

9493
def load_invitation

0 commit comments

Comments
 (0)