From 21cdddcbae55e25be4049ad25c590acb5bed71cc Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 16 Jan 2018 19:44:11 +0100 Subject: [PATCH] Order budgets by `created_at` instead of by `id` This is a preventive change which will be useful once the rake to migrate from `spending_proposals` to `budget_investments` is complete As after running that migration, old `spending_proposal` budgets will have a newer `id` than the existing budgets. And therefore the last budget will be one of those migrated from the old `spending_proposal` model By ordering by `created_at` and probably updating the `created_at` attribute in the rake that migrates `spending_proposals` to `budget_investments`, we will have a coherent order for budgets --- app/models/budget.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/budget.rb b/app/models/budget.rb index 608599217..418e9aac0 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -33,7 +33,7 @@ class Budget < ActiveRecord::Base scope :open, -> { where.not(phase: "finished") } def self.current - where.not(phase: "drafting").last + where.not(phase: "drafting").order(:created_at).last end def description