Hello,
I’ve been working on a specific project for longer than I like to
think about. At some point, I had ferret working in such a way that it
would search fields in the HABTM relationship. Now, though, it only
searches fields in the specific model where the search is located. The
application is structured like this:
Models:
providers
procedures
types
destinations
…
provider is where the search in question is located. Thus, it is at
http://localhost:3000/provider/search/. A provider
has_and_belongs_to_many procedures, types, and destinations. Thus,
when I search at the above URL, I want my search to take values that
correspond to those models, as well as the provider model.
provider.rb:
- acts_as_ferret :additional_fields => [
-
:procedure_name,
-
:type_name,
-
:type_field,
-
:destination_name
-
]
- has_and_belongs_to_many :types, :join_table =>
“types_providers” - has_and_belongs_to_many :procedures, :join_table =>
“procedures_providers” - has_and_belongs_to_many :destinations, :join_table =>
“destinations_providers” - def procedure_name
-
return "#{self.procedure.name}"
- end
- def type_name
-
return "#{self.type.name}"
- end
- def type_field
-
return "#{self.type.field}"
- end
- def destination_name
-
return "#{self.destination.name}"
- end
Thus, I defined the additional fields which I would like ferret to
index. It was doing this perfectly until recently, and I have tried
rebuilding the indexes of the above models and tried various other
small edits, but nothing has helped thus far.
Any ideas would be most appreciated. Thanks.
Jon