Sha256: 2339b31702f3e9ed8832547502004b8cc4bcebd41670564fb36c5079d037d876
Contents?: true
Size: 602 Bytes
Versions: 96
Compression:
Stored size: 602 Bytes
Contents
module Spree class TaxCategory < Spree::Base acts_as_paranoid validates :name, presence: true, uniqueness: { case_sensitive: false, scope: :deleted_at } has_many :tax_rates, dependent: :destroy, inverse_of: :tax_category before_save :set_default_category def set_default_category # set existing default tax category to false if this one has been marked as default if is_default && tax_category = self.class.where(is_default: true).where.not(id: id).first tax_category.update_columns(is_default: false, updated_at: Time.current) end end end end
Version data entries
96 entries across 96 versions & 1 rubygems