Skip to content

Commit

Permalink
Allow exact search
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Jan 11, 2024
1 parent 43f595b commit 7abad71
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def show
cond_text = filter_names.map{|w| "LOWER(entries.body) like ?"}.join(" OR ")
cond_values = filter_names.map{|w| "%#{w}%"}
@entries = current_user.entries.where(cond_text, *cond_values)
elsif search_params[:term].include?('"')
exact_phrase = search_params[:term].delete('"')
@entries = current_user.entries.where("entries.body ~* ?", "\\m#{exact_phrase}\\M")
else
@search = Search.new(search_params)
@entries = @search.entries
Expand Down

0 comments on commit 7abad71

Please sign in to comment.