Class: Spree::TaxCategory

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

Instance Method Summary collapse

Methods inherited from Base

page

Methods included from Preferences::Preferable

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

Instance Method Details

#set_default_categoryObject


10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/spree/tax_category.rb', line 10

def set_default_category
  #set existing default tax category to false if this one has been marked as default

  if is_default && tax_category = self.class.where(is_default: true).first
    unless tax_category == self
      tax_category.update_columns(
        is_default: false,
        updated_at: Time.now,
      )
    end
  end
end