mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Update has_many_through on Order
Fixes:
384) Spree::OrderMailer basic behaviour doesn't aggressively escape double quotes in confirmation body
Failure/Error: adjustments = adjustments.to_a + order.shipment_adjustments.to_a
ActionView::Template::Error:
Cannot have a has_many :through association 'Spree::Order#shipment_adjustments' which goes through 'Spree::Order#shipments' before the through association is defined.
# ./app/helpers/checkout_helper.rb:10:in `checkout_adjustments_for'
# ./app/views/spree/order_mailer/_order_summary.html.haml:43:in `_app_views_spree_order_mailer__order_summary_html_haml__2911251238692323485_70331958934800'
# ./app/views/spree/order_mailer/confirm_email_for_customer.html.haml:23:in `_app_views_spree_order_mailer_confirm_email_for_customer_html_haml__3734564010704881256_70331959518520'
# ./app/mailers/spree/order_mailer.rb:35:in `block in confirm_email_for_customer'
# ./app/mailers/spree/order_mailer.rb:33:in `confirm_email_for_customer'
# ./spec/mailers/order_mailer_spec.rb:20:in `block (3 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# ActiveRecord::HasManyThroughOrderError:
# Cannot have a has_many :through association 'Spree::Order#shipment_adjustments' which goes through 'Spree::Order#shipments' before the through association is defined.
# ./app/helpers/checkout_helper.rb:10:in `checkout_adjustments_for'
This commit is contained in:
@@ -42,16 +42,16 @@ module Spree
|
||||
as: :adjustable,
|
||||
dependent: :destroy
|
||||
|
||||
has_many :line_item_adjustments, through: :line_items, source: :adjustments
|
||||
has_many :shipment_adjustments, through: :shipments, source: :adjustments
|
||||
has_many :all_adjustments, class_name: 'Spree::Adjustment', dependent: :destroy
|
||||
|
||||
has_many :shipments, dependent: :destroy do
|
||||
def states
|
||||
pluck(:state).uniq
|
||||
end
|
||||
end
|
||||
|
||||
has_many :line_item_adjustments, through: :line_items, source: :adjustments
|
||||
has_many :shipment_adjustments, through: :shipments, source: :adjustments
|
||||
has_many :all_adjustments, class_name: 'Spree::Adjustment', dependent: :destroy
|
||||
|
||||
belongs_to :order_cycle
|
||||
belongs_to :distributor, class_name: 'Enterprise'
|
||||
belongs_to :customer
|
||||
|
||||
Reference in New Issue
Block a user