mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-06 07:29:16 +00:00
Fix "undefined method 'association_class' for nil:NilClass" error when creating Migs payment gateway
This commit is contained in:
10
app/models/spree/gateway_decorator.rb
Normal file
10
app/models/spree/gateway_decorator.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
Spree::Gateway.class_eval do
|
||||
|
||||
# Due to class load order, when config.cache_classes is enabled (ie. staging and production
|
||||
# environments), this association isn't inherited from PaymentMethod. As a result, creating
|
||||
# payment methods using payment gateways results in:
|
||||
# undefined method `association_class' for nil:NilClass
|
||||
# To avoid that, we redefine this association here.
|
||||
|
||||
has_and_belongs_to_many :distributors, join_table: 'distributors_payment_methods', :class_name => 'Enterprise', foreign_key: 'payment_method_id', association_foreign_key: 'distributor_id'
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
Spree::PaymentMethod.class_eval do
|
||||
# See gateway_decorator.rb when modifying this association
|
||||
has_and_belongs_to_many :distributors, join_table: 'distributors_payment_methods', :class_name => 'Enterprise', association_foreign_key: 'distributor_id'
|
||||
|
||||
attr_accessible :distributor_ids
|
||||
|
||||
Reference in New Issue
Block a user