From 1001e14cdfbc5e863db1651191448573e19b09d1 Mon Sep 17 00:00:00 2001 From: Stephen Corwin Date: Fri, 25 Jun 2021 11:18:38 -0400 Subject: [PATCH 1/2] Don't call upstream if nothing found via friendly ID search --- lib/friendly_id/finder_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/friendly_id/finder_methods.rb b/lib/friendly_id/finder_methods.rb index 1f8ea8267..03bcdd00a 100644 --- a/lib/friendly_id/finder_methods.rb +++ b/lib/friendly_id/finder_methods.rb @@ -28,7 +28,7 @@ def find(*args) def exists?(conditions = :none) return super if conditions.unfriendly_id? return true if exists_by_friendly_id?(conditions) - super + false end # Finds exclusively by the friendly id, completely bypassing original From 4fad564bebc2f29b88479cd9b1aba2a74a201f39 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Mon, 19 Jul 2021 22:30:06 +1200 Subject: [PATCH 2/2] Convert from guard clause --- lib/friendly_id/finder_methods.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/friendly_id/finder_methods.rb b/lib/friendly_id/finder_methods.rb index 03bcdd00a..6bcf49b04 100644 --- a/lib/friendly_id/finder_methods.rb +++ b/lib/friendly_id/finder_methods.rb @@ -27,8 +27,8 @@ def find(*args) # Returns true if a record with the given id exists. def exists?(conditions = :none) return super if conditions.unfriendly_id? - return true if exists_by_friendly_id?(conditions) - false + + exists_by_friendly_id?(conditions) end # Finds exclusively by the friendly id, completely bypassing original