Saturday, October 28, 2006

rails text search

This tutorial shows you how to search your data at your Rails application. we will use an easy, and flixible plugin called ferret.

ready? follow up:
  • install ferret gem:
gem install ferret
  • install ferret plugin:
script/plugin install svn://projects.jkraemer.net/acts_as_ferret/tags/stable/acts_as_ferret
  • at your model add the following line:
act_as_ferret or customize your search to only some fields like this: act_as_ferret :fields => [:name, :firstname, :surename]
  • now your database fields are searchable.
to search your data type: .find_by_contents("osama OR dwairi") and walk through them as array