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



27
28
29
# File 'app/models/spree/tax_category.rb', line 27

def self.default
  find_by(is_default: true)
end

Instance Method Details

#ensure_one_defaultObject



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

def ensure_one_default
  if is_default
    Spree::TaxCategory.where(is_default: true).where.not(id:).update_all(is_default: false, updated_at: Time.current)
  end
end