Permalink
Browse files

Add association-filtered faceting to CollectionProxy

  • Loading branch information...
1 parent ed22a0e commit ecb085404bdf3bf904826875cb30abfd8a7e5b40 @pixeltrix pixeltrix committed Jul 18, 2012
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/thinking_sphinx/active_record/collection_proxy.rb
@@ -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

0 comments on commit ecb0854

Please sign in to comment.