Class: Spree::TaxCategory

Inherits:
Base
  • Object
show all
Includes:
SoftDeletable
Defined in:
app/models/spree/tax_category.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

display_includes

Methods included from Core::Permalinks

#generate_permalink, #save_permalink

Class Method Details

.defaultObject



25
26
27
# File 'app/models/spree/tax_category.rb', line 25

def self.default
  find_by(is_default: true)
end

Instance Method Details

#ensure_one_defaultObject



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

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