From 4bbc51bfb93c6e4b181f3bc216b65236ad102455 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 6 Aug 2017 05:05:10 +0200 Subject: [PATCH] Remove return in scope block Return in scope fails with `LocalJumpError: unexpected return` --- app/models/person.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 0fa77b3d7..f8add5a52 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -100,10 +100,12 @@ class Person < ApplicationRecord # @return [Person::ActiveRecord_Relation] scope :find_by_substring, ->(search_str) { search_str.strip! - return none if search_str.blank? || search_str.size < 2 - - sql, tokens = search_query_string(search_str) - joins(:profile).where(sql, *tokens) + if search_str.blank? || search_str.size < 2 + none + else + sql, tokens = search_query_string(search_str) + joins(:profile).where(sql, *tokens) + end } # Left joins likes and comments to a specific post where people are authors of these comments and likes