Forum: Ferret how to index and search multiple foreign keys in aaf

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9952cc9c6265ca60726d9b5843ea0dc8?d=identicon&s=25 Levent Ali (Guest)
on 2007-05-15 17:40
(Received via mailing list)
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
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2007-05-15 19:06
(Received via mailing list)
On Tue, May 15, 2007 at 04:39:41PM +0100, Levent Ali 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
kraemer@webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
This topic is locked and can not be replied to.