Class: District

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/district.rb

Instance Method Summary collapse

Instance Method Details

#full_nameObject



21
22
23
# File 'app/models/district.rb', line 21

def full_name
  [province.name, city_name, name].compact.join(' - ')
end

#provinceObject



17
18
19
# File 'app/models/district.rb', line 17

def province
  city.province
end

#short_nameObject



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

def short_name
  @short_name ||= name.gsub(/区|县|市|自治县/, '')
end

#siblingsObject



29
30
31
# File 'app/models/district.rb', line 29

def siblings
  @siblings ||= where(nil).for_city(city_id)
end