Automatic association (re)indexing for your searchable Sunspot models.
class User < ActiveRecord::Base
belongs_to :company
searchable do
associate :text, :company, :name, :phone
end
end
The above example will convert to:
searchable do
text :company_name do; company.name end
text :company_phone do; company.phone end
end
It will also hook into Company
and watch it for changes
Add to your Gemfile:
gem 'sunspot_association', '~> 0.2.1'
class User < ActiveRecord::Base
belongs_to :company
searchable do
associate :text, :company, :name, :phone
associate :string, :company, :address, :stored => true
# Converts to:
# => text :company_name do; company.name end
# => text :company_phone do; company.phone end
# => string :company_address, { :stored => true } do; company.address end
end
end
class Company < ActiveRecord::Base
has_many :users
# This configuration is automatically added by the searchable DSL
# => sunspot_associate :users, :fields => [:name, :phone, :address]
end
sunspot_association is distributed under the MIT License, copyright © 2013 Arjen Oosterkamp