In your variable @headsear you have both : Heading objects and Section objects If you want these results into 2 variables, you can call search method twice :
@headings = Heading.search {fulltext params[:search]}
@sections = Section.search {fulltext params[:search]}
Another solution is to search only Heading and used the relation with Section :
You need to index section data into Heading class like this : heading.rb
class Heading < ActiveRecord::Base
belongs_to :section
searchable do
text :name
text :address
text :phone
text(:section_name) { section.name }
end
end
After this when name of a section match with search param, the result will contain all heading object related
Hope this help.