Sha256: 6123ecd238624b70831e5a82f7df2342eeacc477968149735ebb98e781b7f9ee

Contents?: true

Size: 889 Bytes

Versions: 9

Compression:

Stored size: 889 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.define_indexes
        (@reflection.klass.sphinx_indexes || []).each do |index|
          attribute = index.attributes.detect { |attrib|
            attrib.columns.length == 1 &&
            attrib.columns.first.__name  == foreign_key.to_sym
          }
          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

9 entries across 9 versions & 4 rubygems

Version Path
skalee-thinking-sphinx-1.3.14.2 lib/thinking_sphinx/active_record/has_many_association.rb
skalee-thinking-sphinx-1.3.14.1 lib/thinking_sphinx/active_record/has_many_association.rb
hawkerb-thinking-sphinx-1.3.18 lib/thinking_sphinx/active_record/has_many_association.rb
hawkerb-thinking-sphinx-1.3.17 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.15 lib/thinking_sphinx/active_record/has_many_association.rb
hawkerb-thinking-sphinx-1.3.16 lib/thinking_sphinx/active_record/has_many_association.rb
hawkerb-thinking-sphinx-1.3.15 lib/thinking_sphinx/active_record/has_many_association.rb
hawkerb-thinking-sphinx-1.3.14 lib/thinking_sphinx/active_record/has_many_association.rb
zipme-thinking-sphinx-1.3.14 lib/thinking_sphinx/active_record/has_many_association.rb