# How to index and search multiple foreign keys in aaf

**URL:** <https://www.ruby-forum.com/t/how-to-index-and-search-multiple-foreign-keys-in-aaf/104225>\
**Category:** Ferret\
**Created:** [May 15, 2007, 5:40pm UTC](https://www.ruby-forum.com/t/how-to-index-and-search-multiple-foreign-keys-in-aaf/104225 "2007-05-15T17:40:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![levent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@levent](https://www.ruby-forum.com/u/levent)\
**Post date:** [May 15, 2007, 5:40pm UTC](https://www.ruby-forum.com/t/how-to-index-and-search-multiple-foreign-keys-in-aaf/104225/1 "2007-05-15T17:40:34Z")

</div>

Let’s say I have a class Job that has a series of possible locations  
that are stored as a sequence of foreign keys

class Job  
acts\_as\_ferret {  
:locations =\> {}  
}

def locations  
“1,25,23,15”  
# ??  
end  
end

Is that a good way to store the location ids?

How would I search for Jobs in a certain location

Job.find\_by\_contents(‘locations(25)’)

cheers

---

<div class="post-metadata">

**Author:** ![levent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@levent](https://www.ruby-forum.com/u/levent)\
**Post date:** [May 15, 2007, 7:06pm UTC](https://www.ruby-forum.com/t/how-to-index-and-search-multiple-foreign-keys-in-aaf/104225/2 "2007-05-15T19:06:08Z")

</div>

On Tue, May 15, 2007 at 04:39:41PM +0100, Levent A. wrote:

> ```
> # ??
> 
> ```
> 
> end  
> end
> 
> Is that a good way to store the location ids?
> 
> How would I search for Jobs in a certain location
> 
> Job.find\_by\_contents(‘locations(25)’)

I’d say ‘locations:25’ but besides that this looks like it could work.  
To be on the safe side do not separate the ids with ‘,’ but with ’ '.

Jens

–  
Jens Krämer  
webit! Gesellschaft für neue Medien mbH  
Schnorrstraße 76 | 01069 Dresden  
Telefon +49 351 46766-0 | Telefax +49 351 46766-66  
removed\_email\_address@domain.invalid | [www.webit.de](http://www.webit.de)

Amtsgericht Dresden | HRB 15422  
GF Sven Haubold, Hagen Malessa
