diff --git a/app/models/spree/payment_method_decorator.rb b/app/models/spree/payment_method_decorator.rb index 4cbb7e85d9..ebe5a68ad2 100644 --- a/app/models/spree/payment_method_decorator.rb +++ b/app/models/spree/payment_method_decorator.rb @@ -10,7 +10,7 @@ Spree::PaymentMethod.class_eval do after_initialize :init - validates_with DistributorsValidator + validate :distributor_validation # -- Scopes scope :managed_by, lambda { |user| @@ -73,4 +73,10 @@ Spree::PaymentMethod.class_eval do name[i..-1] end end + + private + + def distributor_validation + validates_with DistributorsValidator + end end diff --git a/app/models/spree/shipping_method_decorator.rb b/app/models/spree/shipping_method_decorator.rb index 837fd45ee6..55f79c946b 100644 --- a/app/models/spree/shipping_method_decorator.rb +++ b/app/models/spree/shipping_method_decorator.rb @@ -6,7 +6,7 @@ Spree::ShippingMethod.class_eval do after_save :touch_distributors - validates_with DistributorsValidator + validate :distributor_validation scope :managed_by, lambda { |user| if user.has_spree_role?('admin') @@ -80,4 +80,8 @@ Spree::ShippingMethod.class_eval do def touch_distributors distributors.each(&:touch) end + + def distributor_validation + validates_with DistributorsValidator + end end