From 7458dccea6b3e265e8de1408f528fee3f168ecc4 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 21 Oct 2022 16:49:42 +0100 Subject: [PATCH] Call @order_cycles.count instead of #size because TagRuleApplicator doesn't return Relation anymore In March 2020 this was changed to use :size instead of :count because TagRuleApplicator returned an ActiveRecord::Relation, see: https://github.com/openfoodfoundation/openfoodnetwork/commit/d2eee1dafdeb83e5f4864a22420a1f35b7cd066d However in October 2020 TagRuleApplicator was changed to always return an Array so this is no longer needed, see: https://github.com/openfoodfoundation/openfoodnetwork/commit/7e606471e48fee77104abbb5c816c7f9c79889cc --- app/controllers/base_controller.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 952c66afee..f235694085 100644 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -22,12 +22,8 @@ class BaseController < ApplicationController end # Default to the only order cycle if there's only one - # - # Here we need to use @order_cycles.size not @order_cycles.count - # because OrderCyclesList returns a modified ActiveRecord::Relation - # and these modifications are not seen if it is reloaded with count def set_order_cycle - return if @order_cycles.size != 1 + return if @order_cycles.count != 1 current_order(true).set_order_cycle! @order_cycles.first end