mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix Rails/HasManyOrHasOneDependent with nullify
This commit is contained in:
@@ -13,7 +13,7 @@ module Spree
|
||||
belongs_to :state, class_name: "Spree::State"
|
||||
|
||||
has_one :enterprise, dependent: :restrict_with_exception
|
||||
has_many :shipments
|
||||
has_many :shipments, dependent: :nullify
|
||||
|
||||
validates :address1, :city, :country, :phone, presence: true
|
||||
validates :company, presence: true, unless: -> { first_name.blank? || last_name.blank? }
|
||||
|
||||
@@ -7,7 +7,7 @@ module Spree
|
||||
belongs_to :payment_method
|
||||
belongs_to :user
|
||||
|
||||
has_many :payments, as: :source
|
||||
has_many :payments, as: :source, dependent: :nullify
|
||||
|
||||
before_save :set_last_digits
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ module Spree
|
||||
belongs_to :payment_method, class_name: 'Spree::PaymentMethod'
|
||||
|
||||
has_many :offsets, -> { where("source_type = 'Spree::Payment' AND amount < 0").completed },
|
||||
class_name: "Spree::Payment", foreign_key: :source_id
|
||||
class_name: "Spree::Payment", foreign_key: :source_id, dependent: :nullify
|
||||
has_many :log_entries, as: :source, dependent: :destroy
|
||||
|
||||
has_one :adjustment, as: :adjustable, dependent: :destroy
|
||||
|
||||
@@ -8,8 +8,8 @@ module Spree
|
||||
|
||||
belongs_to :order, class_name: 'Spree::Order', inverse_of: :return_authorizations
|
||||
|
||||
has_many :inventory_units, inverse_of: :return_authorization
|
||||
has_one :stock_location
|
||||
has_many :inventory_units, inverse_of: :return_authorization, dependent: :nullify
|
||||
has_one :stock_location, dependent: :nullify
|
||||
before_save :force_positive_amount
|
||||
before_create :generate_number
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module Spree
|
||||
class ShippingCategory < ApplicationRecord
|
||||
validates :name, presence: true
|
||||
has_many :products
|
||||
has_many :products, dependent: :nullify
|
||||
has_many :shipping_method_categories, inverse_of: :shipping_method, dependent: :destroy
|
||||
has_many :shipping_methods, through: :shipping_method_categories
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ module Spree
|
||||
class Taxonomy < ApplicationRecord
|
||||
validates :name, presence: true
|
||||
|
||||
has_many :taxons
|
||||
has_many :taxons, dependent: :nullify
|
||||
has_one :root, -> { where parent_id: nil }, class_name: "Spree::Taxon", dependent: :destroy
|
||||
|
||||
after_save :set_name
|
||||
|
||||
@@ -33,9 +33,9 @@ module Spree
|
||||
has_many :enterprise_roles, dependent: :destroy
|
||||
has_many :enterprises, through: :enterprise_roles
|
||||
has_many :owned_enterprises, class_name: 'Enterprise',
|
||||
foreign_key: :owner_id, inverse_of: :owner
|
||||
foreign_key: :owner_id, inverse_of: :owner, dependent: :nullify
|
||||
has_many :owned_groups, class_name: 'EnterpriseGroup',
|
||||
foreign_key: :owner_id, inverse_of: :owner
|
||||
foreign_key: :owner_id, inverse_of: :owner, dependent: :nullify
|
||||
has_many :customers, dependent: :destroy
|
||||
has_many :credit_cards, dependent: :destroy
|
||||
has_many :report_rendering_options, class_name: "::ReportRenderingOptions", dependent: :destroy
|
||||
|
||||
Reference in New Issue
Block a user