From 08babeed65ab97d8df89ea70f5f1177169f90f08 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 19 Aug 2013 12:05:25 +1000 Subject: [PATCH] Payment Method must have one Distributor --- app/models/spree/payment_method_decorator.rb | 2 ++ ...dd_distributor_to_admin_payment_method_edit.html.haml.deface | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/spree/payment_method_decorator.rb b/app/models/spree/payment_method_decorator.rb index f8759ac06b..095b6b5dfc 100644 --- a/app/models/spree/payment_method_decorator.rb +++ b/app/models/spree/payment_method_decorator.rb @@ -1,5 +1,7 @@ Spree::PaymentMethod.class_eval do belongs_to :distributor, :class_name => 'Enterprise' + + validates_presence_of :distributor_id attr_accessible :distributor_id diff --git a/app/overrides/spree/admin/payment_methods/_form/add_distributor_to_admin_payment_method_edit.html.haml.deface b/app/overrides/spree/admin/payment_methods/_form/add_distributor_to_admin_payment_method_edit.html.haml.deface index 8ac8e7aad9..d15ecec373 100644 --- a/app/overrides/spree/admin/payment_methods/_form/add_distributor_to_admin_payment_method_edit.html.haml.deface +++ b/app/overrides/spree/admin/payment_methods/_form/add_distributor_to_admin_payment_method_edit.html.haml.deface @@ -5,5 +5,5 @@ = f.label :distributor %br - = collection_select(:payment_method, :distributor_id, Enterprise.is_distributor.managed_by(spree_current_user), :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"}) + = collection_select(:payment_method, :distributor_id, Enterprise.is_distributor.managed_by(spree_current_user), :id, :name, {:include_blank => false}, {:class => "select2 fullwidth"}) = f.error_message_on :distributor