Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default_scope implemented #495

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/pg_search/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def alias(*strings)
end
end

def default_scope
return nil unless options[:default_scope]

options[:default_scope]
end

def columns
regular_columns + associated_columns
end
Expand Down Expand Up @@ -84,7 +90,7 @@ def default_options
end

VALID_KEYS = %w[
against ranked_by ignoring using query associated_against order_within_rank
against ranked_by ignoring using query associated_against order_within_rank default_scope
].map(&:to_sym)

VALID_VALUES = {
Expand Down
1 change: 1 addition & 0 deletions lib/pg_search/scope_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def subquery
.select("#{primary_key} AS pg_search_id")
.select("#{rank} AS rank")
.joins(subquery_join)
.where(config.default_scope)
.where(conditions)
.limit(nil)
.offset(nil)
Expand Down