Module: SearchApi::Integration::ActiveRecord::Associations

Defined in:
lib/search_api/active_record_integration.rb

Overview

This module allows the ActiveRecord::Base associations to transparently integrate SearchApi::Search::Base features.

class People < ActiveRecord::Base
  belongs_to :company
  has_search_api

  # define age search key
  search :age do |search|
    { :conditions => ['birth_date BETWEEN ? AND ?',
                      (Date.today-search.age.years),
                      (Date.today-(search.age-1).years+1.day)]}
  end
end

some_company.people.find(:all, :conditions => {:first_name => 'Roger', :age => 30})

Defined Under Namespace

Modules: Count, Find