How to search for a string on multiple fields across multiple joined tables in Rails

Published on Author Akhil Bansal2 Comments

In my project I have to write a search controller, in which I have to search for a string on multiple fields across join tables.

There are two controllers Project, Publication and two models project and publication.
Project has many publication and publication belongs to project.

I wanted to search for a string on all fields of project and publications. For that I wrote a query in which I have to mention all the fields on which I wanted to search.
This was fine, but after some days I found a plugin: TextSearch. This changed the whole stuff.

This is a very useful plugin for search and you should try this.
For more detail please visit http://wiki.rubyonrails.org/rails/pages/TextSearch

2 Responses to How to search for a string on multiple fields across multiple joined tables in Rails

Leave a Reply to personallo Cancel reply

Your email address will not be published. Required fields are marked *