From fcc47bcfccc7578aa0414710eecdad006085a911 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sat, 27 May 2017 14:36:18 +0200 Subject: [PATCH] Use non-raising finder. `find` raises when it can't find a record, so we'll never reach the else. Switch to `find_by` which returns nil when no record can be found. --- activesupport/lib/active_support/current_attributes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/current_attributes.rb b/activesupport/lib/active_support/current_attributes.rb index 2251f56aef..9921241c23 100644 --- a/activesupport/lib/active_support/current_attributes.rb +++ b/activesupport/lib/active_support/current_attributes.rb @@ -31,7 +31,7 @@ module ActiveSupport # # private # def authenticate - # if authenticated_user = User.find(cookies.signed[:user_id]) + # if authenticated_user = User.find_by(id: cookies.signed[:user_id]) # Current.user = authenticated_user # else # redirect_to new_session_url