Merge pull request #7606 from luisramos0/deprecation

[Rails 6.1] Fix deprecation warning in rails 6.0
This commit is contained in:
Andy Brett
2021-06-04 07:42:50 -07:00
committed by GitHub
3 changed files with 4 additions and 3 deletions

View File

@@ -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')

View File

@@ -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

View File

@@ -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