Search code examples
searchlogicruby-on-rails

Search Logic removing records with no association from results when ordering by that association


I'm using search logic to filter and order my results but it removes records from my results when I order by a association and when that association is not always present for all records.

For example say I have a user model which can have one vehicle model but does not have to, if I have a results table where you can order by the users vehicles make I would hope all users without a vehicle record would be considered empty strings and therefore ordered all at the beginning followed by the other user records which have vehicles ordered by the make name.

Unfortunately all the user records which do not have a vehicle are removed from the results.

Is there anyway round this and still use search logic as I find it extremely useful


Solution

  • I think you'll have to explicitly assign a default vehicle that has an empty name