diff --git a/promotions/app/models/solidus_promotions/promotion.rb b/promotions/app/models/solidus_promotions/promotion.rb index e36015facac..7eacbbf61af 100644 --- a/promotions/app/models/solidus_promotions/promotion.rb +++ b/promotions/app/models/solidus_promotions/promotion.rb @@ -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 diff --git a/promotions/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb b/promotions/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb index ee23a457469..0310fc54ceb 100644 --- a/promotions/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb +++ b/promotions/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb @@ -48,6 +48,10 @@ def create private + def model_class + SolidusPromotions::PromotionCode + end + def load_promotion @promotion = SolidusPromotions::Promotion .accessible_by(current_ability, :show)