Sha256: 4460f07414ba5dc8ae9423c58be9f011942fc1c0a8f25882291c3e722ae3ceb8
Contents?: true
Size: 630 Bytes
Versions: 2
Compression:
Stored size: 630 Bytes
Contents
# # Region/Province/Estado # class Region include Mongoid::Document include Geopolitocracy field :timezone, type: String belongs_to :nation has_many :cities, dependent: :destroy belongs_to :capital, inverse_of: :region_capital, class_name: 'City' validates :nation, presence: true validates :name, uniqueness: { scope: :nation_id } validates :abbr, uniqueness: { scope: :nation_id, allow_nil: true } index abbr: 1 index nation_id: 1, name: 1 # National dialing code / or International def phone self[:phone] || nation.phone end def postal self[:postal] || nation.postal end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
geopolitical-1.0.5 | app/models/region.rb |
geopolitical-1.0.3 | app/models/region.rb |