Module: PgSearch::ScopeOptions::WithPgSearchRank

Defined in:
lib/pg_search/scope_options.rb

Instance Method Summary collapse

Instance Method Details

#with_pg_search_rankObject



47
48
49
50
51
52
53
# File 'lib/pg_search/scope_options.rb', line 47

def with_pg_search_rank
  scope = self
  scope = scope.select(arel_table[Arel.star]) if scope.select_values.empty?
  rank_table = arel_table.alias(pg_search_rank_table_alias)
  rank_column = Arel::Attributes::Attribute.new(rank_table, "rank")
  scope.select(rank_column.as("pg_search_rank"))
end