In acts_as_ferret, excluding records from rebuild_index

Is there any way for the automatic ‘rebuild_index’ of ‘acts_as_ferret’
from exclude certain records from being included in the index?

On Tue, Mar 06, 2007 at 12:02:17PM +0100, Ted wrote:

Is there any way for the automatic ‘rebuild_index’ of ‘acts_as_ferret’
from exclude certain records from being included in the index?

rebuild_index uses Model.find(:all), so if you override that to not
return all records (as acts_as_paranoid does to not include records
marked as deleted) this will be possible.

Another way would be to patch rebuild_index so it only indexes records
where ferret_enabled? returns true. You could then override this method
to check whatever condition to determine if the record should be
indexed.

For 0.3.1/stable simply change line 205 in class_methods.rb from
index << rec.to_doc
to
index << rec.to_doc if rec.ferret_enabled?

I think I’ll add this check in the next release.

Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa