Rails association and multiple indexes


If I have two models, Product and Manufacturer, of course Product
belongs_to :manufacturer.

A search engine would allow a user to look for a product by its name or
manufacturer. Is it better to define a method like:

def searchable_field
“#{name} #{manufacturer.name}”

and add it as indexable field (acts_as_ferret :fields =>

Or maybe that it is more advisable to index different fields:

Product < ActiveRecord::Base
acts_as_ferret :fields => [‘name’, ‘manufacturer_name’]

def manufacturer_name


Thanks in advance.

On 10/22/06, Rodrigo A. [email protected] wrote:


Thanks in advance.

Hi Rodrigo,

It’s better to index individual fields. You can easily search both
fields like this:


I can’t really think of any advantages to putting buth fields into the
one search field.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs