Sha256: e4c1dad5729f51d1c1ab25832e0fb0abf798c1ab43ef293a23b80cc8bc73229c

Contents?: true

Size: 894 Bytes

Versions: 10

Compression:

Stored size: 894 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.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

10 entries across 10 versions & 5 rubygems

Version Path
DrMark-thinking-sphinx-0.9.7 lib/thinking_sphinx/active_record/has_many_association.rb
DrMark-thinking-sphinx-0.9.8 lib/thinking_sphinx/active_record/has_many_association.rb
DrMark-thinking-sphinx-0.9.9 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-0.9.5 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-0.9.6 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-0.9.7 lib/thinking_sphinx/active_record/has_many_association.rb
freelancing-god-thinking-sphinx-0.9.8 lib/thinking_sphinx/active_record/has_many_association.rb
nixme-thinking-sphinx-0.9.7 lib/thinking_sphinx/active_record/has_many_association.rb
ryanb-thinking-sphinx-0.9.8 lib/thinking_sphinx/active_record/has_many_association.rb
ryanb-thinking_sphinx-0.9.8 lib/thinking_sphinx/active_record/has_many_association.rb