# Aaf 0.4.4 index population bug?

**URL:** <https://www.ruby-forum.com/t/aaf-0-4-4-index-population-bug/174075>\
**Category:** Ferret\
**Created:** [August 20, 2009, 1:22pm UTC](https://www.ruby-forum.com/t/aaf-0-4-4-index-population-bug/174075 "2009-08-20T13:22:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [August 20, 2009, 1:22pm UTC](https://www.ruby-forum.com/t/aaf-0-4-4-index-population-bug/174075/1 "2009-08-20T13:22:00Z")

</div>

Hi Jens,

I am using Ferret 11.6 and aaf 0.4.4. I am using LocalIndex in  
development environment as I have not gotten to production stage yet.

There seems to be a bug where the Ferret index is not being populated  
versus the old behavior in 0.4.3.

I am calling acts\_as\_ferret in my models as opposed to using aaf.rb  
(since the latter is not documented anywhere but in the code!). Also, at  
this point, no index exists in index directory.

It seems, based on my understanding of the source, that when  
ensure\_index\_exists/rebuild\_index is initially called, internally via a  
long chain of methods, from acts\_as\_ferret (when the model class is  
loaded), index\_definition[:registered\_models] is the empty array. Hence,  
index.index\_models(models) doesn’t populate the newly created Ferret  
index.

When ensure\_index\_exists is called the second time around, internally  
via a long chain of methods from find\_with\_ferret, rebuild\_index doesn’t  
get called again because #{index\_definition[:index\_dir]}/segments exists  
due to the Ferret index coming into existence in the first rebuild\_index  
call. It’s a shame because this time around  
index\_definition[:registered\_models] IS populated due to an earlier call  
to index.register\_class(clazz, options). Had rebuild\_index been called,  
the Ferret index would get poopulated with documents.

Could you confirm my understanding please? If I read the code correctly,  
then it seems the fix should reside on this line  
index\_definition[:registered\_models] = Object.const\_get(name) | []

I don’t use ActsAsFerret::define\_index directly but I suppose for those  
who do, my suggestion would break the code for them. It would be nice if  
you could come up with something that would work for all supported use  
cases since it took days for me to get this far.

Thanks,  
Richard
