Skip to content

Commit

Permalink
Add inverse_of to Promotion#codes association
Browse files Browse the repository at this point in the history
This helps fix an issue when creating a new promotion with a single
code. Without the inverse_of parameter, our associated codes won't
correctly infer that they're associated to a new promotion and will
generate undefined method for nil errors.

Co-authored-by: Alistair Norman <[email protected]>
(cherry picked from commit 2cb9ac1)
  • Loading branch information
adammathys committed Dec 6, 2024
1 parent bfdf4bb commit a1038fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion promotions/app/models/solidus_promotions/promotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Promotion < Spree::Base
belongs_to :original_promotion, class_name: "Spree::Promotion", optional: true
has_many :benefits, class_name: "SolidusPromotions::Benefit", dependent: :destroy
has_many :conditions, through: :benefits
has_many :codes, class_name: "SolidusPromotions::PromotionCode", dependent: :destroy
has_many :codes, class_name: "SolidusPromotions::PromotionCode", dependent: :destroy, inverse_of: :promotion
has_many :code_batches, class_name: "SolidusPromotions::PromotionCodeBatch", dependent: :destroy
has_many :order_promotions, class_name: "SolidusPromotions::OrderPromotion", dependent: :destroy

Expand Down

0 comments on commit a1038fd

Please sign in to comment.