Skip to content

Commit

Permalink
Add missing inverse_of for shipping_rate and taxes
Browse files Browse the repository at this point in the history
Determining the shipping_rate_tax's currency delegates all the way back
to the order, which was causing unnecessary selects of the
shipping_rate, shipment, and order because the inverse_of couldn't be
determined.
  • Loading branch information
jhawthorn committed Oct 19, 2017
1 parent c2f1f5f commit ef2e350
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Shipment < Spree::Base

has_many :adjustments, as: :adjustable, inverse_of: :adjustable, dependent: :delete_all
has_many :inventory_units, dependent: :destroy, inverse_of: :shipment
has_many :shipping_rates, -> { order(:cost) }, dependent: :destroy
has_many :shipping_rates, -> { order(:cost) }, dependent: :destroy, inverse_of: :shipment
has_many :shipping_methods, through: :shipping_rates
has_many :state_changes, as: :stateful
has_many :cartons, -> { uniq }, through: :inventory_units
Expand Down
1 change: 1 addition & 0 deletions core/app/models/spree/shipping_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ShippingRate < Spree::Base
has_many :taxes,
class_name: "Spree::ShippingRateTax",
foreign_key: "shipping_rate_id",
inverse_of: :shipping_rate,
dependent: :destroy

delegate :order, :currency, to: :shipment
Expand Down

0 comments on commit ef2e350

Please sign in to comment.