Skip to content
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.

Commit

Permalink
Finally fix Article.text_search ordering
Browse files Browse the repository at this point in the history
Years to fix this damn thing and now we finally get proper prioritization
because all it took was removing the order from the existing scope because
all that really matters on a search is the order that the full-text search engine
gave.

This is the worst and best thing all wrapped into one.
  • Loading branch information
olivierlacan committed Jul 24, 2017
1 parent bf054f1 commit 05cdb21
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def self.text_search(query, scope = nil)
scope ||= current

if query.present?
scope.search(query).with_pg_search_highlight
scope.reorder(nil).search(query).with_pg_search_highlight
else
scope
end
Expand Down
2 changes: 0 additions & 2 deletions spec/models/article_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@
before do
@title_match = create(:article, title: "Security Best Practices")
@content_match = create(:article, content: "We have a number of security best practices, some of which don't make a lot of sense.")

skip "not working right yet"
end

subject(:search) { Article.text_search("security best practices") }
Expand Down

0 comments on commit 05cdb21

Please sign in to comment.