# AAF association not workin

**URL:** <https://www.ruby-forum.com/t/aaf-association-not-workin/110147>\
**Category:** Ferret\
**Created:** [July 23, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/aaf-association-not-workin/110147 "2007-07-23T20:18:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![izit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/87869e/32.png) [@izit](https://www.ruby-forum.com/u/izit)\
**Post date:** [July 23, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/aaf-association-not-workin/110147/1 "2007-07-23T20:18:53Z")

</div>

Hi,

I have configured my model as follows:

class Product \< ActiveRecord::Base

acts\_as\_ferret :fields =\>  
[:description,:label\_description,:label\_free,:product\_id\_supplier,:description\_supplier,:supplier\_description]

belongs\_to :supplier

def supplier\_description  
return “#{self.supplier.description}”  
end

In the development log I can see the supplier\_description being added to  
the index:

creating doc for class: Product, id: 24710306  
Adding field label\_free with value ‘67CM’ to index  
Adding field product\_id\_supplier with value ‘177-175-078 middel’ to  
index  
Supplier Load (0.000359) SELECT \* FROM suppliers WHERE  
(suppliers.`id` = 19)  
Adding field supplier\_description with value ‘Haans’ to index  
Adding field description with value ‘MAND RATTAN MIDDEL 67CM’ to index  
Adding field description\_supplier with value ‘’ to index  
Adding field label\_description with value ‘MAND RATTAN MIDDEL’ to index

But when I do a Product.find\_by\_contents(“Haans”) I get nothing back.

=\> #\<ActsAsFerret::SearchResults:0x3514b88 @total\_hits=0, @results=[]\>

The development log shows:

Query: Haans  
total hits: 0, results delivered: 0

Does anybody know why my association does not work. Other searches on  
fields in the Product model work fine.

---

<div class="post-metadata">

**Author:** ![izit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/87869e/32.png) [@izit](https://www.ruby-forum.com/u/izit)\
**Post date:** [July 24, 2007, 8:18am UTC](https://www.ruby-forum.com/t/aaf-association-not-workin/110147/2 "2007-07-24T08:18:59Z")

</div>

I got it working but in a very strange way.

If I deleted the index directory and AAF recreated it automatically on  
the first search my search did not work.  
BUT if I do Model.rebuild\_index to rebuild the index my search DOES  
work.

Izit I. wrote:

> Hi,
> 
> I have configured my model as follows:
> 
> class Product \< ActiveRecord::Base
> 
> acts\_as\_ferret :fields =\>  
> [:description,:label\_description,:label\_free,:product\_id\_supplier,:description\_supplier,:supplier\_description]
> 
> belongs\_to :supplier
> 
> def supplier\_description  
> return “#{self.supplier.description}”  
> end
> 
> In the development log I can see the supplier\_description being added to  
> the index:
> 
> creating doc for class: Product, id: 24710306  
> Adding field label\_free with value ‘67CM’ to index  
> Adding field product\_id\_supplier with value ‘177-175-078 middel’ to  
> index  
> Supplier Load (0.000359) SELECT \* FROM suppliers WHERE  
> (suppliers.`id` = 19)  
> Adding field supplier\_description with value ‘Haans’ to index  
> Adding field description with value ‘MAND RATTAN MIDDEL 67CM’ to index  
> Adding field description\_supplier with value ‘’ to index  
> Adding field label\_description with value ‘MAND RATTAN MIDDEL’ to index
> 
> But when I do a Product.find\_by\_contents(“Haans”) I get nothing back.
> 
> =\> #\<ActsAsFerret::SearchResults:0x3514b88 @total\_hits=0, @results=[]\>
> 
> The development log shows:
> 
> Query: Haans  
> total hits: 0, results delivered: 0
> 
> Does anybody know why my association does not work. Other searches on  
> fields in the Product model work fine.
