Sha256: f84288c29069af8871c850b2a7cc2658886dd39d80ebe2aae304e39cdd8ae7a8
Contents?: true
Size: 662 Bytes
Versions: 36
Compression:
Stored size: 662 Bytes
Contents
module Spree class TaxCategory < Spree::Base acts_as_paranoid validates :name, presence: true, uniqueness: { scope: :deleted_at, allow_blank: true } 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).first unless tax_category == self tax_category.update_columns( is_default: false, updated_at: Time.now, ) end end end end end
Version data entries
36 entries across 36 versions & 1 rubygems