Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit cc7d2ef

Browse files
author
Bill Heaton
committed
Support phrase searches for Posts
1 parent f6d42c0 commit cc7d2ef

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

app/models/post.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def self.search(terms)
1414
if terms.blank?
1515
none
1616
else
17-
query = sanitize_sql_array(["to_tsquery('pg_catalog.english', ?)", terms.gsub(/\s/,"+")])
17+
terms = CGI.unescape(terms)
18+
query = sanitize_sql_array(["to_tsquery('pg_catalog.english', ?)", terms.gsub(/\s/," & ")])
1819
self.where("tsv @@ #{query}").order("ts_rank_cd(tsv, #{query}) DESC")
1920
end
2021
end

0 commit comments

Comments
 (0)