From 73fe247c3d72a17c09e3f83028e3b886a281a191 Mon Sep 17 00:00:00 2001 From: mfo Date: Wed, 5 Jun 2024 14:21:58 +0200 Subject: [PATCH] feat(avis): ensure consistent ordering, use ASC ordering to give back most recent avis first --- app/models/dossier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 54c187169..e609323bb 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -59,7 +59,7 @@ class Dossier < ApplicationRecord has_many :previous_follows, -> { inactive }, class_name: 'Follow', inverse_of: :dossier has_many :followers_instructeurs, through: :follows, source: :instructeur has_many :previous_followers_instructeurs, -> { distinct }, through: :previous_follows, source: :instructeur - has_many :avis, inverse_of: :dossier, dependent: :destroy + has_many :avis, -> { order(:created_at) }, inverse_of: :dossier, dependent: :destroy has_many :experts, through: :avis has_many :traitements, -> { order(:processed_at) }, inverse_of: :dossier, dependent: :destroy do def passer_en_construction(instructeur: nil, processed_at: Time.zone.now)