acts_as_ferret gives you a powerful search capability, and it’s much easier to implement than MySQL full text querying.
In development mode,
it’s as simple as adding something like this to your model:
acts_as_ferret :fields => [ :city, :state ]
and this to your controller:
@users = User.find_by_contents(params[:keywords])
But the problem is in the production mode:
I started getting all kinds of corrupted index errors when I put this into production, because acts_as_ferret can’t handle multiple separate processes access the index at once and starting givinng errors as the file not found.
And the answer is also the same and simple:
You have to add :remote => true to your acts_as_ferret declaration,
setup a ferret_server.yaml config file,
If you installed it using script/plugin install, a configuration file stub already has been created in config/ferret_server.yml. In that file you can define the DRb server hostname/ip address and port for each Rails environment (similar to database.yml). Usually you’ll only want this for production mode:
production: host: ferret.yourdomain.com port: 9009 pid_file: log/ferret.pid
The pid file path is relative to RAILS_ROOT and is used by the start/stop scripts.
RAILS_ENV=production script/runner vendor/plugins/acts_as_ferret/script/ferret_server start
in some older versions the command is:
RAILS_ENV=production script/runner “load ‘script/ferret_server'” start
RAILS_ENV=production script/runner “load ‘script/ferret_server'” stop
to start ans stop the server