Hi!
On Mon, Jun 25, 2007 at 12:42:54AM +0200, Stephen Heuer wrote:
> I am trying to use acts_as_ferret's multi_search to search across
> multiple models, but i only want it to return one type of model.
>
> for example i have a page that lists out people. on this page it shows
> email addresses and phone numbers. I want to be able to search by any
> fields directly from the person model and search the fields from the
> email_address and phone_number models, but I only want to get back
> people.
>
> person
> has_many email_addresses
> has_many phone_numbers
> acts_as_ferret :fields => [:firstname, :lastname, :birth_date]
>
> email_address
> has_one person
> acts_as_ferret :fields => [:email_address]
>
> phone_number
> has_one person
> acts_as_ferret :fields => [:phone_number, :phone_type]
>
>
>
> multi_search(options[:query], ["EmailAddress", "PhoneNumber"], {:limit
> => :all})
>
> Is this the right way of doing this... or is there a better way?
Be sure to apply the :store_classname => true option to all your
acts_as_ferret calls. Otherwise aaf cannot filter results by class.
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
[EMAIL PROTECTED] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk