# Aaf and dynamic attrs: a bug?

**URL:** <https://www.ruby-forum.com/t/aaf-and-dynamic-attrs-a-bug/105549>\
**Category:** Ferret\
**Created:** [May 31, 2007, 12:37am UTC](https://www.ruby-forum.com/t/aaf-and-dynamic-attrs-a-bug/105549 "2007-05-31T00:37:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e0b2c6/32.png) [@yura](https://www.ruby-forum.com/u/yura)\
**Post date:** [May 31, 2007, 12:37am UTC](https://www.ruby-forum.com/t/aaf-and-dynamic-attrs-a-bug/105549/1 "2007-05-31T00:37:45Z")

</div>

Hi!

I faced some issue while using it for dynamic attrs indexing/search.  
Maybe I made something wrong. Here is test method. Everything works just  
fine until last line [Parked at Loopia](http://pastie.caboo.se/66274) . Tested on both  
stable and trunk of aaf and ferret 0.11.4.

the short version of code below:

Contact.acts\_as\_ferret :fields =\> [:first\_name]  
assert Contact.find(:first).respond\_to?(:first\_name\_to\_ferret)

assert\_equal 1, Contact.find\_by\_contents(‘Y\*’).total\_hits  
assert\_equal 1, Contact.find\_by\_contents(‘first\_name:Y\*’).total\_hits

Contact.aaf\_index.close  
FileUtils.rm\_rf ‘index’

Contact.acts\_as\_ferret :fields =\> [:first\_name, :last\_name]  
assert Contact.find(:first).respond\_to?(:last\_name\_to\_ferret)

assert\_equal 1, Contact.find\_by\_contents(‘Y\*’).total\_hits  
assert\_equal 1, Contact.find\_by\_contents(‘first\_name:Y\*’).total\_hits

assert\_equal 1, Contact.find\_by\_contents(‘last\_name:K\*’).total\_hits  
assert\_equal 1, Contact.find\_by\_contents(‘K\*’).total\_hits # assertion  
fails here: get 0 instead of 1 !!

Maybe there is any better solution to add new fields to existing index?

Best regards,  
Yury K.
