Class: District
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- District
- Defined in:
- app/models/district.rb
Instance Method Summary collapse
Instance Method Details
#full_name ⇒ Object
21 22 23 |
# File 'app/models/district.rb', line 21 def full_name [province.name, city_name, name].compact.join(' - ') end |
#province ⇒ Object
17 18 19 |
# File 'app/models/district.rb', line 17 def province city.province end |
#short_name ⇒ Object
25 26 27 |
# File 'app/models/district.rb', line 25 def short_name @short_name ||= name.gsub(/区|县|市|自治县/, '') end |
#siblings ⇒ Object
29 30 31 |
# File 'app/models/district.rb', line 29 def siblings @siblings ||= where(nil).for_city(city_id) end |