Ask A Question


You’re not receiving notifications from this thread.

Search all models gem

Ali Rizvi asked in Gems / Libraries

I have seen this done in other rails application where you can search for a term and it would search across multiple models and return results from each. What is the best gem to use for this purpose?

Is there a episode in GoRails for Searching and Filtering?



Searchkick with Elasticsearch is pretty good for searching models and is very flexible. It's my go-to solution with searching.

Here's an episode on Searchkick

You could also look into using Ransack I believe is another popular gem for it.


Like Andrew said, Searchkick is perfect for this. Each model gets an index inside ElasticSearch and then searchkick lets you query over those by simply doing this: All that should make sense after watching the screencast. 😎

Ransack isn't quite the same in that it doesn't index them in a way that you could search multiple models together. You'd actually have to search each table separately and then combine the results in your view. It's nothing fancy as it just does database queries which makes it really easy to implement without any separate services, but more rudimentary in a sense.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.