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