Skip to content

Commit

Permalink
Do case-insensitive exact match searching
Browse files Browse the repository at this point in the history
closes #178
  • Loading branch information
hackartisan committed Oct 9, 2023
1 parent ffd6597 commit 3114e06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/guide_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class GuideCard < ApplicationRecord

# First, try to find an exact match. Otherwise, find the closest match.
def self.search_result(term)
match = GuideCard.find_by(heading: term)
match = GuideCard.find_by('heading ilike ?', term)
return match if match.present?

GuideCard.where('heading < ?', term).order(heading: :desc).limit(1).first
Expand Down
6 changes: 6 additions & 0 deletions spec/system/search_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,11 @@
click_on '1'
expect(page).to have_link('AALAS')
end
it 'ignores capitalization' do
visit '/'
fill_in 'search_term', with: 'aaron'
click_on 'Go'
expect(page).to have_link('* Aaron')
end
end
end

0 comments on commit 3114e06

Please sign in to comment.