A similar question has already been asked
Sunspot rails: include associated models when calling .results
search = Sunspot.search(ArticlePost, Post, User, Group) do
fulltext query
with(:api_search_shared, true)
paginate :page => page, :per_page => 100
end
what i want to do is include a few other tables with the query something like that:
include [{:user => [:user_job_title, :user_departments], :group => []}]
How would you go about go about putting the include in for when you are searching multiple models?
This is an example of a Single one:
Event.search(:include => [:user]) do...
this solution works for me :
search_in = [Post, Tweet]
search = Sunspot.search search_in do
search_in.each{|m|data_accessor_for(m).include = [:user]}
[...]
end
Hope this solution help.
Have a nice day :)