To edit pages or tickets please login with username/password: aaf/aaf

Ticket #96 (assigned enhancement)

Opened 2 years ago

Last modified 1 year ago

[PATCH] Allow passing an association as :fields or :additional_fields

Reported by: divoxx@gmail.com Assigned to: jk (accepted)
Priority: major Milestone: 0.5
Component: 0plugin Version:
Keywords: Cc: matt@expectedbehavior.com

Description

This patch allows you to pass an association as :fields or :additional_fields Altough, it removes the possibility of referencing a instance variable, but isn't a better practice setup an accessor for instance variables?

The patch iterates over the associated objects calling either to_index or to_s in each of the objects and pushing the returned value to a string, which will be indexed.

Example:

class Person < ActiveRecord::Base
  acts_as_ferret :additional_fields => [:addresses]
  has_many :addresses
end

class Address < ActiveRecord::Base
  def to_index
    "#{self.address} #{self.city} #{self.state} #{self.country}"
  end
end

Person.find_by_contents("addresses: *whathever*")

I couldn't find the perfect place to document that, so.... :)

Attachments

aaf_support_association.174.diff (0.9 kB) - added by divoxx@gmail.com on 03/30/07 18:18:04.

Change History

03/30/07 18:18:04 changed by divoxx@gmail.com

  • attachment aaf_support_association.174.diff added.

06/19/07 08:38:11 changed by jk

  • owner changed from somebody to jk.
  • status changed from new to assigned.
  • milestone set to 0.5.

06/19/07 08:40:00 changed by jk

  • cc set to matt@expectedbehavior.com.

To edit pages or tickets please login with username/password: aaf/aaf