In attempting to search child models (returning the parent object)
using part of the
“# Descend child elements” script
at
I get a “no method” error for “all_fields”. Does anyone know why this
could be or where in fact the method comes from. If it works its a
good solution unless anyone knows of any another way of searching
child models while still returning the parent object.
His script is:
Descend child elements
self.class.reflect_on_all_associations.collect { |association|
self.send(association.instance_values[“name”]).collect { |
child|
child.to_doc.all_fields.collect { |field|
doc << field
} if child.class.respond_to?(“acts_as_ferret”)
}
}
To use: extend the acts_as_ferret to_doc method by copying it into the
parent model and add the above code onto the end of it before the
return of doc.
Incidentally I use the code below instead (hard coding a child model)
but still have the same problem.
self.products.each do |product|
product.to_doc.all_fields.collect { |field| doc <<
field}
end
I appreciate any help…my deadline looms!
Eddie