Class: Stay::Country

Inherits:
ApplicationRecord show all
Defined in:
app/models/stay/country.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default(store = nil) ⇒ Object



11
12
13
14
15
16
# File 'app/models/stay/country.rb', line 11

def self.default(store = nil)
  store ||= Stay::Store.default
  country_id = store.default_country_id
  default = find_by(id: country_id) if country_id.present?
  default || find_by(iso: 'US') || first
end

.ransackable_attributes(auth_object = nil) ⇒ Object



7
8
9
# File 'app/models/stay/country.rb', line 7

def self.ransackable_attributes(auth_object = nil)
  ["name"]
end

Instance Method Details

#default?(store = nil) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'app/models/stay/country.rb', line 18

def default?(store = nil)
  store ||= Stay::Store.default
  self == store.default_country
end