私はプロモーションを通じて商品にアクセスしようとしていますが、できません。コマンドラインでプロモーションルールから製品が動作しないための対応
:Promotion.last.promotion_rules.first.products
が初期化されていない定数のエラーを返します。ここで
は私の団体です:
has_many :product_promotion_rules, class_name: 'ProductPromotionRule', foreign_key: :product_id
has_many :promotion_rules, through: :product_promotion_rules, source: :promotion_rule
そしてPromotionRuleモデル内:製品モデルの試みの中で
class Product
has_many :product_promotion_rules, class_name: 'ProductPromotionRule'
has_many :promotion_rules, through: :product_promotion_rules
end
class ProductPromotionRule
belongs_to :product
belongs_to :promotion_rule
end
class PromotionRule
has_many :product_promotion_rules, class_name: 'ProductPromotionRule', join_table: 'products_promotion_rules', foreign_key: :promotion_rule_id
has_many :products, through: :product_promotion_rules
belongs_to :promotion
end
class Promotion
has_many :promotion_rules
end
エラーを表示してください。 – MTarantini
NameError:初期化されていない定数Promotion :: Rules :: ProductValue :: ProductPromotionRule –