samedi 25 avril 2015

Rails 4 + Solr: Show search result from different model


I have search method in my controller:

def search
  @search = Sunspot.search [Post, Siri] do
    fulltext params[:q]
  end
  @posts = @search.results
end

Then i have this in my view:

- @posts.each do |p|
  %h5= p.title

My question is how to show separately in view if @posts from Post model & if @posts from Siri model.

The reason that i want it seperately is because there is some attr are not exists in Post model but exists in Siri model.

Thanks in advance!


Aucun commentaire:

Enregistrer un commentaire