Reorder has_many relationship with :through option

If it's using :through it should be defined after the relationship it's connected to
This commit is contained in:
Matt-Yorkley
2021-05-01 16:20:36 +01:00
parent 8672969798
commit 9d23c0d9e2

View File

@@ -2,9 +2,9 @@
module Spree
class OptionType < ApplicationRecord
has_many :products, through: :product_option_types
has_many :option_values, -> { order(:position) }, dependent: :destroy
has_many :product_option_types, dependent: :destroy
has_many :products, through: :product_option_types
validates :name, :presentation, presence: true
default_scope -> { order("#{table_name}.position") }