Class: Spree::TaxCategory

Inherits:
Base
  • Object
show all
Includes:
Discard::Model, ParanoiaDeprecations
Defined in:
core/app/models/spree/tax_category.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ParanoiaDeprecations

#paranoia_delete, #paranoia_destroy

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Class Method Details

.defaultObject



31
32
33
# File 'core/app/models/spree/tax_category.rb', line 31

def self.default
  find_by(is_default: true)
end

Instance Method Details

#ensure_one_defaultObject



35
36
37
38
39
# File 'core/app/models/spree/tax_category.rb', line 35

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