Fix Rails/HasManyOrHasOneDependent with nil

This commit is contained in:
Neal Chambers
2023-08-30 09:33:26 +09:00
parent 019b54ea95
commit 7f8ac94933
4 changed files with 5 additions and 5 deletions

View File

@@ -36,7 +36,7 @@ module Spree
# Deletion of metadata is handled in the database.
# So we don't need the option `dependent: :destroy` as long as
# AdjustmentMetadata has no destroy logic itself.
has_one :metadata, class_name: 'AdjustmentMetadata', dependent: :destroy
has_one :metadata, class_name: 'AdjustmentMetadata', dependent: nil
has_many :adjustments, as: :adjustable, dependent: :destroy
belongs_to :adjustable, polymorphic: true

View File

@@ -21,7 +21,7 @@ module Spree
belongs_to :zone, class_name: "Spree::Zone", inverse_of: :tax_rates
belongs_to :tax_category, class_name: "Spree::TaxCategory", inverse_of: :tax_rates
has_many :adjustments, as: :originator, dependent: :destroy
has_many :adjustments, as: :originator, dependent: nil
validates :amount, presence: true, numericality: true
validates :tax_category, presence: true

View File

@@ -14,7 +14,7 @@ module Spree
encryptor: 'authlogic_sha512', reconfirmable: true,
omniauth_providers: [:openid_connect]
has_many :orders
has_many :orders, dependent: nil
belongs_to :ship_address, class_name: 'Spree::Address'
belongs_to :bill_address, class_name: 'Spree::Address'

View File

@@ -33,8 +33,8 @@ module Spree
delegate :name, :name=, :description, :description=, :meta_keywords, to: :product
has_many :inventory_units, inverse_of: :variant, dependent: :destroy
has_many :line_items, inverse_of: :variant, dependent: :destroy
has_many :inventory_units, inverse_of: :variant, dependent: nil
has_many :line_items, inverse_of: :variant, dependent: nil
has_many :stock_items, dependent: :destroy, inverse_of: :variant
has_many :stock_locations, through: :stock_items