Fix "undefined method 'association_class' for nil:NilClass" error when creating Migs payment gateway

This commit is contained in:
Rohan Mitchell
2014-05-01 17:13:07 +10:00
parent c9aefa507a
commit 4480c75494
2 changed files with 11 additions and 0 deletions

View 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

View File

@@ -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