Remove return in scope block

Return in scope fails with `LocalJumpError: unexpected return`
This commit is contained in:
Benjamin Neff 2017-08-06 05:05:10 +02:00
parent 150fea6edb
commit 4bbc51bfb9
No known key found for this signature in database
GPG key ID: 971464C3F1A90194

View file

@ -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