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.
Levent A. (Guest)
on 2007-05-15 19: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
Jens K. (Guest)
on 2007-05-15 21:06
(Received via mailing list)
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

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