I have three models (User
, Tag
, Product
) and they interact s.t. User
has many Tags
and Products
.
I like the idea of a Search object if you are doing any complicated conditions.
But to search across objects using Sunspot:
@sunspot_search = Sunspot.search User, Tag, Product do |query|
query.keywords @search_query
query.with(:age).greater_than 20
query.with(:age).less_than 25
query.paginate(:page => params[:page], :per_page => 30)
end