Sha256: 57458100f60b86e4dfe76d614435eca1cbd7b5bea014ded75b52cf13f2378452
Contents?: true
Size: 616 Bytes
Versions: 7
Compression:
Stored size: 616 Bytes
Contents
module Spree class TaxCategory < Spree::Base acts_as_paranoid validates :name, presence: true, uniqueness: { scope: :deleted_at } has_many :tax_rates, dependent: :destroy 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
7 entries across 7 versions & 1 rubygems