diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index f77e634e96..c6e4a6f272 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -121,7 +121,7 @@ class Enterprise < ApplicationRecord scope :not_ready_for_checkout, lambda { # When ready_for_checkout is empty, return all rows when there are no enterprises ready for # checkout. - ready_enterprises = Enterprise.ready_for_checkout. + ready_enterprises = Enterprise.default_scoped.ready_for_checkout. except(:select). select('DISTINCT enterprises.id') diff --git a/app/models/spree/shipment.rb b/app/models/spree/shipment.rb index 2db789a98d..dd4cb87fe6 100644 --- a/app/models/spree/shipment.rb +++ b/app/models/spree/shipment.rb @@ -309,7 +309,7 @@ module Spree record = true while record random = "H#{Array.new(11) { rand(9) }.join}" - record = self.class.find_by(number: random) + record = self.class.default_scoped.find_by(number: random) end self.number = random end diff --git a/lib/spree/core/permalinks.rb b/lib/spree/core/permalinks.rb index b667de7b2c..70092ef6b7 100644 --- a/lib/spree/core/permalinks.rb +++ b/lib/spree/core/permalinks.rb @@ -49,8 +49,9 @@ module Spree # Do other links exist with this permalink? other = self.class. - where("#{self.class.table_name}.#{field} LIKE ?", "#{permalink_value}%") + default_scoped.where("#{self.class.table_name}.#{field} LIKE ?", "#{permalink_value}%") if other.any? + # Find the existing permalink with the highest number, and increment that number. # (If none of the existing permalinks have a number, this will evaluate to 1.) number = other.map { |o| o.__send__(field)[/-(\d+)$/, 1].to_i }.max + 1