diff --git a/lib/pg_search/configuration.rb b/lib/pg_search/configuration.rb index ce37edf9..ceadb40e 100644 --- a/lib/pg_search/configuration.rb +++ b/lib/pg_search/configuration.rb @@ -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 @@ -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 = { diff --git a/lib/pg_search/scope_options.rb b/lib/pg_search/scope_options.rb index 369a603a..3e48cfd3 100644 --- a/lib/pg_search/scope_options.rb +++ b/lib/pg_search/scope_options.rb @@ -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)