rails, gem tanker, search through several models

88 views Asked by At

I'm using Searchify (IndexTank) in my rails app. Everything works perfect with separate models. I added tanker conf to my models (ex. Question model):

class Question < ActiveRecord::Base
  attr_accessible :name, :user_id
  self.per_page = 2

  has_many :comments
  belongs_to :user

  include Tanker
  tankit 'uaebb_dev' do
    indexes :name
  end

  after_save :update_tank_indexes
  after_destroy :delete_tank_indexes
end

Here is action from question controller

def search
  @questions = Question.search_tank(params[:search])
  render :index
end

This code works perfect. But I have several models (Question, Item ...) which have search functionality. Is there way to search through all models in app (like general search)? I know that I can do:

@questions = Question.search_tank(params[:search])
@items = Item.search_tank(params[:search])
....

But it doesn't look like very good solution. Is there any better way using tanker gem?

0

There are 0 answers