class Transport::Vehicle < ApplicationRecord
has_one :driver, class_name: "Admin", foreign_key: "driver_id"
end
Transport::Vehicle.joins(:driver)
produces the following SQL query
SELECT "transport_vehicles".* FROM "transport_vehicles" INNER JOIN "admins" ON "admins"."driver_id" = "transport_vehicles"."id" AND "admins"."deleted_at" IS NULL LIMIT $1
But it should be
SELECT "transport_vehicles".* FROM "transport_vehicles" INNER JOIN "admins" ON "admins"."id" = "transport_vehicles"."id" AND "admins"."deleted_at" IS NULL LIMIT $1
How can i get admin.id instead of admins.driver_id ??
Aucun commentaire:
Enregistrer un commentaire