Class: PgSearch::ScopeOptions
- Inherits:
-
Object
- Object
- PgSearch::ScopeOptions
- Defined in:
- lib/pg_search_multiple_highlight/scope_options.rb
Overview
Extends standard scope options for pg_search so :multiple_highlight can be used the same way as other search options
Defined Under Namespace
Modules: WithPgSearchMultipleHighlight
Instance Method Summary collapse
Instance Method Details
#apply(scope) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pg_search_multiple_highlight/scope_options.rb', line 7 def apply(scope) scope = include_table_aliasing_for_rank(scope) rank_table_alias = scope.pg_search_rank_table_alias(include_counter: true) scope .joins(rank_join(rank_table_alias)) .order(Arel.sql("#{rank_table_alias}.rank DESC, #{order_within_rank}")) .extend(WithPgSearchRank) .extend(WithPgSearchHighlight[feature_for(:tsearch)]) .extend(WithPgSearchMultipleHighlight[feature_for(:tsearch)]) end |