mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
Fix deprecation warning in rails 6.0
Warning: Class level methods will no longer inherit scoping from create in Rails 6.1
This commit is contained in:
@@ -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')
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user