| Module | SearchApi::Integration::ActiveRecord::Associations::Find |
| In: |
lib/active_record_integration.rb
|
Module that holds integration of SearchApi::Search::Base into ActiveRecord::Associations::HasManyAssociation, ActiveRecord::Associations::HasAndBelongsToManyAssociation, and ActiveRecord::Associations::HasManyThroughAssociation.
Alteration of the :find method that has support for search keys added by the search method.
# File lib/active_record_integration.rb, line 148
148: def find_with_search_support(*args)
149: if @reflection.klass.respond_to?(:search_class)
150: options = if args.last.is_a?(Hash) then args.last else {} end
151: if options[:conditions].nil? || options[:conditions].is_a?(Hash)
152: @reflection.klass.with_scope(:find => @reflection.klass.search_class.new(options.delete(:conditions)).find_options) do
153: find_without_search_support(*args)
154: end
155: else
156: find_without_search_support(*args)
157: end
158: else
159: find_without_search_support(*args)
160: end
161: end