How to make Searchkick return what was passed on the search box plus what was chosen in the dropdown?

48 views Asked by At

Can someone point me to the right direction on how to make Searchkick only return what was passed on the search box plus what was chosen in the category dropdown?

So here's how my current Searchkick feature works. I added Searchkick to my model business.rb and this belongs to the model category.rb.

I already implemented the basic usage of Searchkick which is to return what was passed on the search box e.g. I passed the address "Sample 123 St." and it will return all businesses of all categories with that address.

But now, I want to only return what was passed on the search box plus what was chosen on the category dropdown e.g. I passed the address "Sample 123 St." and chose "School" in the dropdown category and will only return "School" with that address.

1

There are 1 answers

0
Jayaprakash On

Try to add the category id in where conditions.

Like this

Business.search "search text", where: {category_id: YOUR_DROPDOWN_SELECTED_CATEGORYID}