From 4ad9adc5105dff71c5acd3484df60e6943bce0a2 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 4 Feb 2021 12:59:10 +0100 Subject: [PATCH] models: fix Ruby 2.7 arguments passing Arguments to an ActiveRecord scope will always been passed as a Dictionnary. Thus `Dossier.with_notifiable_procedure(notify_on_closed: true)` will trigger a Ruby 2.7 warning: > /ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:412: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call Fix the issue by always expecting a Dictionary (rather than keyword arguments). --- app/models/dossier.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index a763570c1..59ea1f07a 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -227,8 +227,8 @@ class Dossier < ApplicationRecord user: []) } - scope :with_notifiable_procedure, -> (notify_on_closed: false) do - states = notify_on_closed ? [:publiee, :close, :depubliee] : [:publiee, :depubliee] + scope :with_notifiable_procedure, -> (opts = { notify_on_closed: false }) do + states = opts[:notify_on_closed] ? [:publiee, :close, :depubliee] : [:publiee, :depubliee] joins(:procedure) .where(procedures: { aasm_state: states }) end