Liberate Your Search in Rails with Tags

Search is an essential part of any website, even more so for a content-centric website. A good search system is a fast one that provides accurate results. Search and filter are mostly the same depending on how you look at it. For this article, I’ll treat search and filter as the same kind of function.

There are many existing methods to implement search from the tools we use like PostgreSQL full text search, which you can use in Rails. Today, however, we’ll see how to implement tag-based filtering in an Rails app using PostgreSQL.

Let’s get started.

About the Implementation

Let’s see how the tag based implementation works. Assume we have a table called companies and it has the following relation association chain:

companies -> BELONGS_TO -> cities -> BELONGS_TO -> states -> BELONGS_TO -> countries

Continue reading %Liberate Your Search in Rails with Tags%


Source: Sitepoint