Sha256: 1ed6a62b9905020a2a9dc27d201c80e6db4e8cb870be02ce80d408e7f68c4dcb
Contents?: true
Size: 531 Bytes
Versions: 21
Compression:
Stored size: 531 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 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: self.id).update_all(is_default: false, updated_at: Time.now) end end end end
Version data entries
21 entries across 21 versions & 1 rubygems