On Thu, May 10, 2007 at 12:48:15PM +0200, Allen Young wrote:
There are about 100 attributes reside in several different tables. That
means I need to define all this methods manually?
that depends - some metaprogramming might help make it a less daunting
task.
i.e.
class OtherClass
define which fields you want to have indexed and how:
def ferret_fields
{ :field1 => { :store => :yes }, … }
end
end
class MyModel
collect field list for aaf
ferret_fields = { :name => {}, … }
ferret_fields.update! OtherClass.ferret_fields
acts_as_ferret :fields => ferret_fields
define getters
OtherClass.ferret_fields.keys.each do |field|
define_method :“ferret_#{field}” do
other_object.send(field)
end
end
end
you can also join various (textual) attributes together and let them
form a single field in the index where this is appropriate.
Indexing data from a lot of relationships is not trivial when it comes
to updating the index - whenever some record changes it’s parent
object(s) (that acts as the root and goes into the Ferret index first)
has to be re-indexed.
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