Why is Activerecord queries returning sorted data

44 views Asked by At

I have the following data As you can see there is a Tale Model and Purpose Model and a Has_many_through join model TalePurposeJoin Now the join table has data as [4,3] but on query tale.purpose_ids I get [3,4] I want to retain the db order. What is activerecord doing behind the scene, why and how do I stop it.

Here is the query sql is generating

SELECT "purposes".id FROM "purposes" INNER JOIN "tale_purpose_joins" ON "purposes"."id" = "tale_purpose_joins"."purpose_id" WHERE "tale_purpose_joins"."tale_id" = ?  [["tale_id", 1]]

Joins

0

There are 0 answers