Sha256: 4c01476fd381a55aff7892378bbb031835e55c0666dee7b6db041db10afa1e85

Contents?: true

Size: 338 Bytes

Versions: 1

Compression:

Stored size: 338 Bytes

Contents

# frozen_string_literal: true

class District < ActiveRecord::Base
  belongs_to :city

  scope :with_city, ->(city) { where(city_id: city) }

  def province
    city.province
  end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
china_regions-0.4.4 app/models/district.rb