Posts Tagged search

Very Simple Search for Active Records

Okay, you might encounter a need to put very simple search for active record / model in your Rails app and here is it. Put this code in your active record model:

Note this line

columns = [:name, :address, :city, :pin, :ph]

in the code snippet, give your own column names in that array.  This array can contain columns that are string and text type. Lets say you have put these stuff in a class called Person , to search it you need to issue a command like this "Karthik chennai"

This stuff works well with Sqlite, Postgre and MySQL. If you have tried this out with other DB, please add it in comments. Bye.


, , ,

Leave a comment

The web needs more intelligence

There is tremendous scope for A.I researchers in web development. The proof is shown above! ROFL. This also shows that there is a good opportunity to beat Google.

, , , , , ,

Leave a comment

Searching in Rails

Where is it?

OK, in this article, I am going to discuss how to do search in Rails. Searching can be split into three levels namely

Light: When you just need to search a column in a table who’s length isn’t great or does not have much content. To do that kind of search, you can refer this good video on Railscasts

Moderate: In this category we need to search probably more than one column in a table(s), who’s size is quiet great, like say upto a few tens of megabytes of text data. You can use a plugin called ransack which would accomplish this job.

Heavy: Lets say that our database size is going in gigabytes(s), then you must need a kinda professional search. So there is one, thankfully! And its a free software too. You could use Thinking Sphinx which will scale up almost unlimited amount!

Well if you have implemented any one of the above methods, do tell me how it is.

, ,

Leave a comment

%d bloggers like this: