Acts_as_ferret extra (polymorphic) fields

Hi,

I have a class with some polymorphic associations to it. I want to use
acts_as_ferret to index my objects and its associations. I want to do
it in a way I can define the fields from the associations to be
indexed in the association class.

I know I could do something like:

acts_as_ferret :fields => [:title, :body, :author_name]
has_one :author

def author_name
author.name
end

but since the relationship is polymorphic it woul be like

acts_as_ferret :fields => [:title, :body, :extra_field]
belongs_to :extra, :polymorphic=>true

def extra_field
case self.extra_type
when ‘x’
x.name
when ‘y’
y.date
end

what is very ugly and realy not DRY. How can I define in the foreing
class the fields to be indexed?

thanks for any answers! acts_as_ferret seems to be very nice, but I
fell it lacks some docs.

Bruno

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