Skip to content

Commit

Permalink
Add association-filtered faceting to CollectionProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltrix committed Jul 18, 2012
1 parent ed22a0e commit ecb0854
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/thinking_sphinx/active_record/collection_proxy.rb
Expand Up @@ -2,16 +2,23 @@ module ThinkingSphinx
module ActiveRecord
module CollectionProxy
def search(*args)
options = args.extract_options!
options[:with] ||= {}
options[:with].merge! default_filter
proxy_association.klass.search(*association_args(args))
end

args << options
proxy_association.klass.search(*args)
def facets(*args)
proxy_association.klass.facets(*association_args(args))
end

private

def association_args(args)
options = args.extract_options!
options[:with] ||= {}
options[:with].merge! default_filter

args + [options]
end

def attribute_for_foreign_key
if proxy_association.reflection.through_reflection
foreign_key = proxy_association.reflection.through_reflection.foreign_key
Expand Down

0 comments on commit ecb0854

Please sign in to comment.