Sha256: 53a2122bd2c3ece5ed4357330a0a7d2986db39984023f225042fd54769e424d8
Contents?: true
Size: 771 Bytes
Versions: 34
Compression:
Stored size: 771 Bytes
Contents
# frozen_string_literal: true module Spree class TaxCategory < Spree::Base acts_as_paranoid validates :name, presence: true validates_uniqueness_of :name, unless: :deleted_at has_many :tax_rate_tax_categories, class_name: 'Spree::TaxRateTaxCategory', dependent: :destroy, inverse_of: :tax_category has_many :tax_rates, through: :tax_rate_tax_categories, class_name: 'Spree::TaxRate', inverse_of: :tax_categories after_save :ensure_one_default def self.default find_by(is_default: true) end def ensure_one_default if is_default Spree::TaxCategory.where(is_default: true).where.not(id: id).update_all(is_default: false, updated_at: Time.current) end end end end
Version data entries
34 entries across 34 versions & 2 rubygems