Sha256: 666a92d6e335772355f76539a1afa8e40c9acb8577a662e925bf74d16e845625

Contents?: true

Size: 848 Bytes

Versions: 32

Compression:

Stored size: 848 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
          }
          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

32 entries across 32 versions & 6 rubygems

Version Path
freelancing-god-thinking-sphinx-1.2.11 lib/thinking_sphinx/active_record/has_many_association.rb
hariton-thinking-sphinx-1.2.11.2 lib/thinking_sphinx/active_record/has_many_association.rb
hariton-thinking-sphinx-1.2.11 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.14 lib/thinking_sphinx/active_record/has_many_association.rb
warp-thinking-sphinx-1.3.13 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.13 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.12 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.11 lib/thinking_sphinx/active_record/has_many_association.rb
warp-thinking-sphinx-1.3.11 lib/thinking_sphinx/active_record/has_many_association.rb
warp-thinking-sphinx-1.3.10 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.10 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.9 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.8 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.7 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.6 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.4 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.3 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-099-1.3.2 lib/thinking_sphinx/active_record/has_many_association.rb
thinking-sphinx-1.3.2 lib/thinking_sphinx/active_record/has_many_association.rb
moneypools-thinking-sphinx-1.3.1 lib/thinking_sphinx/active_record/has_many_association.rb