#191 - raise error when environment.rb is not found on DRb startup
[acts_as_ferret.git] / tasks / ferret.rake
blob7b0a7aefdb36d60dd6c3edb20c0afaf5e597c01a
1 namespace :ferret do
3   # for a shared index, declare all models that should go into this index separated by
4   # space: MODEL="MyModel AnotherModel"
5   desc "Rebuild a Ferret index. Specify what model to rebuild with the MODEL environment variable."
6   task :rebuild do
7     require File.join(RAILS_ROOT, 'config', 'environment')
9     models = ENV['MODEL'].split.map(&:constantize)
11     start = 1.minute.ago
12     models.first.rebuild_index( *models )
14     # update records that have changed since the rebuild started
15     models.each do |m|
16       m.records_modified_since(start).each do |object|
17         object.ferret_update
18       end
19     end
20   end
21 end