Reindexing Ferret Part II
Automating the re-indexing process was a bit different than I thought it would be.
Yesterday I posted that you can use script/console. Which is true, but you cant run that in a cronjob. Or, at least I couldnt get it to run in a cronjob.
So I learned about script/runner. I used it like this… I put a .rb script in lib/task called ferret_index.rb.
class FerretIndex < ActiveRecord::Base
MyModel.rebuild_index
end
Then my cronjob
0 1 * * 7 /usr/local/bin/ruby /usr/local/apache2/htdocs/<my project>/script/runner /usr/local/apache2/<my project>/lib/task/ferret_index.rb
Every sunday at 1:00 am my index will be updated.