Posts Tagged 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
Person.search "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.