I have simple search (I want to keep that way) where I can make search Product name. But I want to add other column(Still Product model) intro_text.
Code so far:
Product.rb
def self.search(search)
if search
where('intro_text LIKE ? ', "%#{search}%")
else
where('name LIKE ? ', "%#{search}%")
end
end
Search controller
@products_search = Product.search(params[:search]).paginate(:per_page => 5, :page => params[:page])
At this point when search occurs results are displayed just from intro_text field. Demo: Searching for phrase "Pez" should find all products that consists of this phrase and also all products that intro text consists of this phrase.
Also tried to :
def self.search(search)
if search
where('intro_text LIKE ? ', "%#{search}%") || where('name LIKE ? ', "%#{search}%")
else
end
end
But the result was the same! Can somebody give me some tip? I don't need any search gems.