Sha256: f7a41c2bbd06da9a95a13109e66df2f6fc88d57eabef9cba0b8fe21ce2877349

Contents?: true

Size: 450 Bytes

Versions: 1

Compression:

Stored size: 450 Bytes

Contents

#
# Region/Province/Estado
#
class Region
  include Mongoid::Document
  include Geopolitocracy

  field :timezone, type: String

  belongs_to :nation

  has_many :cities,  dependent: :destroy

  validates :nation, presence: true
  validates :name,   uniqueness: { scope: :nation_id }
  validates :abbr,   uniqueness: { scope: :nation_id }

  def phone
    self[:phone] || nation.phone
  end

  def postal
    self[:postal] || nation.postal
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geopolitical-0.9.1 app/models/region.rb