Sha256: f2056b06dd1800ad65f3be41b741ebc79604fd1e7439971df0f5c43f7ee410d1

Contents?: true

Size: 901 Bytes

Versions: 64

Compression:

Stored size: 901 Bytes

Contents

module ThinkingSphinx
  module ActiveRecord
    module HasManyAssociation
      def search(*args)
        foreign_key = @reflection.primary_key_name
        stack = [@reflection.options[:through]].compact
        
        attribute   = nil
        (@reflection.klass.sphinx_indexes || []).each do |index|
          attribute = index.attributes.detect { |attrib|
            attrib.columns.length == 1 &&
            attrib.columns.first.__name  == foreign_key.to_sym &&
            attrib.columns.first.__stack == stack
          }
          break if attribute
        end
        
        raise "Missing Attribute for Foreign Key #{foreign_key}" unless attribute
        
        options = args.extract_options!
        options[:with] ||= {}
        options[:with][attribute.unique_name] = @owner.id
        
        args << options
        @reflection.klass.search(*args)
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 12 rubygems

Version Path
DrMark-thinking-sphinx-1.1.14 lib/thinking_sphinx/active_record/has_many_association.rb
DrMark-thinking-sphinx-1.1.15 lib/thinking_sphinx/active_record/has_many_association.rb
DrMark-thinking-sphinx-1.1.6 lib/thinking_sphinx/active_record/has_many_association.rb
DrMark-thinking-sphinx-1.2.5 lib/thinking_sphinx/active_record/has_many_association.rb
DrMark-thinking-sphinx-1.2.6 lib/thinking_sphinx/active_record/has_many_association.rb
bterlson-thinking-sphinx-1.2.8 lib/thinking_sphinx/active_record/has_many_association.rb
dpickett-thinking-sphinx-1.1.12 lib/thinking_sphinx/active_record/has_many_association.rb
dpickett-thinking-sphinx-1.1.23 lib/thinking_sphinx/active_record/has_many_association.rb
dpickett-thinking-sphinx-1.1.4 lib/thinking_sphinx/active_record/has_many_association.rb
ebeigarts-thinking-sphinx-1.1.21 lib/thinking_sphinx/active_record/has_many_association.rb
ebeigarts-thinking-sphinx-1.1.22 lib/thinking_sphinx/active_record/has_many_association.rb
ebeigarts-thinking-sphinx-1.2.10 lib/thinking_sphinx/active_record/has_many_association.rb
factorylabs-thinking-sphinx-1.2.7 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-0.9.10 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-0.9.11 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-0.9.12 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-0.9.13 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-1.1.0 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-1.1.1 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-1.1.10 lib/thinking_sphinx/active_record/has_many_association.rb