1

When I chain searchlogix conditions that associate different tables, the results duplicate.

When I chain searchlogix conditions querying fields from a single table, the results work perfectly.

Below is an example of chaining conditions across multiple tables (machine belongs to a manufacturer and machine habtm tools and systems).

Machine.manufacturer_id_equals(params[:search][:manufacturer]) \
.tools_id_equals(params[:search][:tools]) \
.systems_id_equals(params[:search][:systems]

In this query, only 1 valid result should be returned but the same row is returned 8 times (the total results seem to double with each new condition searching different tables).

I assume there is so problem with join, associations, etc.

Update: It appears that (repetitive) results are being returned. Let's say there are 2 valid machine matches. However, the query is returning a match for each tool and system that is related to the machine. So if the machine has 2 tools and 2 systems, it is returned 4 times.

The temporary fix is to call uniq on the returned array, eliminating the repetitive results. However, this feels bad and almost certainly won't scale.

Can anyone provide guidance? Thank you.

John H
  • 31
  • 4

0 Answers0