Class: Spree::TaxCategory

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

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Class Method Details

+ (Object) default



10
11
12
# File 'app/models/spree/tax_category.rb', line 10

def self.default
  find_by(is_default: true)
end

Instance Method Details

- (Object) ensure_one_default



14
15
16
17
18
# File 'app/models/spree/tax_category.rb', line 14

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