diff options
author | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-04-09 08:45:01 -0400 |
---|---|---|
committer | Eugen <eugen@zeonfederated.com> | 2017-04-09 14:45:01 +0200 |
commit | 388ec0d5b6d1549abed15802d6bdbfc8b1c05294 (patch) | |
tree | 218a713f7bd177f964f44a4c3fe0092bddfc5382 /app/models/tag.rb | |
parent | 71706f21c28f5ae623ee69810fe26a34fb79b446 (diff) |
Search cleanup (#1333)
* Clean up SQL output in Tag and Account search methods * Add basic coverage for Tag.search_for * Add coverage for Account.search_for * Add coverage for Account.advanced_search_for
Diffstat (limited to 'app/models/tag.rb')
-rw-r--r-- | app/models/tag.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/tag.rb b/app/models/tag.rb index 15625ca43..6209d7dab 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -17,7 +17,7 @@ class Tag < ApplicationRecord textsearch = 'to_tsvector(\'simple\', tags.name)' query = 'to_tsquery(\'simple\', \'\'\' \' || ' + terms + ' || \' \'\'\' || \':*\')' - sql = <<SQL + sql = <<-SQL.squish SELECT tags.*, ts_rank_cd(#{textsearch}, #{query}) AS rank @@ -25,7 +25,7 @@ class Tag < ApplicationRecord WHERE #{query} @@ #{textsearch} ORDER BY rank DESC LIMIT ? -SQL + SQL Tag.find_by_sql([sql, limit]) end |