About

Hi my name is Andreas Wolff and I'm a freelancing web developer from Berlin, Germany. more

Recent Post

14 Oct 2008 ANN: RSpactor 0.9.21
12 Sep 2008 RSpactor 0.9.19 - Fixing_the_path release
04 Aug 2008 Now on stock: RSpactor 0.9.16
09 Jul 2008 Auto rebuilding Ferret indexes
28 Apr 2008 ANN: RSpactor 0.9.10 (aka. beta)
06 Apr 2008 Whats happening to RSpactor
18 Mar 2008 Getting RubyCocoa on your Mac
11 Mar 2008 Hello world: Introducing RSpactor

Folksonomy

  1. 1 page is tagged with ferret
  2. 2 pages are tagged with mac
  3. 1 page is tagged with rails
  4. 6 pages are tagged with rspactor
  5. 1 page is tagged with rubycocoa

Auto rebuilding Ferret indexes

A few month ago I wrote a little Rails plugin that automatically rebuilds my Ferret indexes if model field definitions have changed. Because I’m currently busy with finishing the next RSpactor release and my blog is so boring at the moment I decided to publish the plugin today. So lets say ‘hey’ to AAFAutoRebuild.

AAFAutoRebuild comes as a rake task and scans all your models for acts_as_ferret field definitions. It keeps the current state of all models in super secret state file in your home directory. If you change a model (e.g. add a field to your aaf call) and rake the task again AAFAutoRebuild diffs the current state with the latest saved and invokes rebuild_index on that model’s class.

rake ferret:index:auto_rebuild

The main purpose behind AAFAutoRebuild was to reduce deploy time when publishing/updating my rails apps with Capistrano. The following cap task gets invoked everytime I deploy my ferret based apps:

desc "Auto rebuild ferret index"
task :rebuild, :roles => [:ferret] do
  run "cd #{current_path}; rake RAILS_ENV=production ferret:index:auto_rebuild"
end

Comments

Canvas said on Monday, August 11, 2008:

I am currently using Rails 2.0.2, ferret 0.11.6, and acts_as_ferret 0.4.3. I know that I need a newer version of Rails to make aaf_auto_rebuild work, but is there an older version of aaf_auto_rebuild to work with Rails 2.0.2?

The error message I am getting is as following:

rake ferret:index:auto_rebuild
(irb):1: warning: parenthesize argument(s) for future version
Syntax error: compile error
(irb):1:syntax error, unexpected ':', expecting $end
rake ferret:index:auto_rebuild

Any help will be appreciated. Thanks.

Canvas said on Monday, August 11, 2008:

I just realized that aaf_auto_rebuild rebuilds Ferret index if model field definitions have changed, it seems more like a deployment tool. But what I really need is to run a background process to incrementally and periodically update/add index entries into ferret index as data in database are being updated and inserted. Any ideas how to do this? Thank you very much.

rubyphunk said on Monday, August 11, 2008:

You're right. aaf_auto_rebuild is primarily meant for use as a deployment tool.

I'm not exactly sure what you need but if you use the acts_as_ferret plugin your models should automatically update their indexes themselves if any data has changed.

Paul said on Wednesday, August 27, 2008:

i had to change

File.basename(model_file, ".rb").classify.constantize

to

File.basename(model_file, ".rb").camelize.constantize

as my model names are already singularized. e.g. 'Address'.singularize => 'Addres' / error !

thanx for the plugin / very useful

Bruno said on Thursday, September 18, 2008:

I had the same exact problem as above and fixed it the same way.

Sapeeaseheaps said on Thursday, October 02, 2008:

Good design! Tnks, owner.
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=188&aid=2378>buy viagra online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=156&aid=2378>buy cialis online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=162&aid=2378>buy levitra online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=177&aid=2378>buy propecia online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=267&aid=2378>buy viagra soft tabs online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=192&aid=2378>buy zithromax online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=1095&aid=2378>buy kamagra online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=251&aid=2378>buy cialis soft tabs online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=262&aid=2378>buy lasix online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=180&aid=2378>buy soma online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=3326&aid=2378>buy clomid online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=1882&aid=2378>buy amoxil online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=252&aid=2378>buy cipro online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=186&aid=2378>buy ultram online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=2959&aid=2378>buy sythroid online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=3052&aid=2378>buy lexapro online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=2957&aid=2378>buy nolvadex online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=159&aid=2378>buy imitrex online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=1095&aid=2378>buy kamagra online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=257&aid=2378>buy diflucan online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=168&aid=2378>buy nexium online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=179&aid=2378>buy retin a online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=767&aid=2378>buy lamisil online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=155&aid=2378>buy celebrex online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=755&aid=2378>buy flomax online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=3325&aid=2378>buy female viagra online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=3259&aid=2378>buy phentrimine online</a>
<a href=http://yandex.ru/redir?url=http://professionalmedicines.com/item.php?id=3104&aid=2378>buy penis growth pills online</a>

Post a comment


(required, but not displayed)

(optional)