mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix deprecated syntax on associations
This commit is contained in:
@@ -9,8 +9,9 @@ module Spree
|
||||
# So we don't need the option `dependent: :destroy` as long as
|
||||
# AdjustmentMetadata has no destroy logic itself.
|
||||
has_one :metadata, class_name: 'AdjustmentMetadata'
|
||||
belongs_to :tax_rate, foreign_key: 'originator_id',
|
||||
conditions: "spree_adjustments.originator_type = 'Spree::TaxRate'"
|
||||
belongs_to :tax_rate, -> { where spree_adjustments: { originator_type: 'Spree::TaxRate' } },
|
||||
foreign_key: 'originator_id'
|
||||
|
||||
|
||||
scope :enterprise_fee, -> { where(originator_type: 'EnterpriseFee') }
|
||||
scope :admin, -> { where(source_type: nil, originator_type: nil) }
|
||||
|
||||
@@ -21,10 +21,9 @@ Spree::Order.class_eval do
|
||||
# This removes "inverse_of: source" which breaks shipment adjustment calculations
|
||||
# This change is done in Spree 2.1 (see https://github.com/spree/spree/commit/3fa44165c7825f79a2fa4eb79b99dc29944c5d55)
|
||||
# When OFN gets to Spree 2.1, this can be removed
|
||||
has_many :adjustments,
|
||||
has_many :adjustments, -> { order "#{Spree::Adjustment.table_name}.created_at ASC" },
|
||||
as: :adjustable,
|
||||
dependent: :destroy,
|
||||
order: "#{Spree::Adjustment.table_name}.created_at ASC"
|
||||
dependent: :destroy
|
||||
|
||||
validates :customer, presence: true, if: :require_customer?
|
||||
validate :products_available_from_new_distribution, if: lambda { distributor_id_changed? || order_cycle_id_changed? }
|
||||
|
||||
Reference in New Issue
Block a user