logo       

Re: search on multiple table: msg#00133

lang.ruby.ferret.general

Subject: Re: search on multiple table

On Sat, Dec 30, 2006 at 10:41:04PM +0100, pierre-yves landanger wrote:
> Hello,
>
> I am trying to make a search, using acts_as_ferret on a
> has_and_belongs_to_many relation :
>
> class a < ActiveRecord::Base
> belongs_to :b
> has_and_belongs_to_many :c
>
> Joboffer.find_by_contents( query +b_id:1 ) is working fine
>
> but
>
> Joboffer.find_by_contents( query +c:1 ) is not working
>
>
> Here are the tables descriptions:
>
> Table a have field : id, b_id
> Table b have field : id, name
> Table c have field : id, name
> Table c_a have field :a_id, c_id
>
> Any idea on how to include c on my search ?

you have to create a method that retrieves the content you want to index
from the c collection belonging to a. Then mention that method name as a
symbol in your field list when you call acts_as_ferret.

Jens


--
webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer
kraemer-jv+WEUQhfkc@xxxxxxxxxxxxxxxx
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise