diff --git a/app/models/customer.rb b/app/models/customer.rb index 933a41dee4..678c4a2d12 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -14,7 +14,7 @@ class Customer < ApplicationRecord searchable_attributes :first_name, :last_name, :email, :code - belongs_to :enterprise + belongs_to :enterprise, optional: false belongs_to :user, class_name: "Spree::User" has_many :orders, class_name: "Spree::Order" before_destroy :update_orders_and_delete_canceled_subscriptions @@ -33,7 +33,6 @@ class Customer < ApplicationRecord validates :code, uniqueness: { scope: :enterprise_id, allow_nil: true } validates :email, presence: true, 'valid_email_2/email': true, uniqueness: { scope: :enterprise_id, message: I18n.t('validation_msg_is_associated_with_an_exising_customer') } - validates :enterprise, presence: true scope :of, ->(enterprise) { where(enterprise_id: enterprise) }