Sha256: 1b0a52a3a8c6ed809813e9b95d4006488e6c611a7ef1e2fbbdc0e8b8aabf45a4

Contents?: true

Size: 467 Bytes

Versions: 1

Compression:

Stored size: 467 Bytes

Contents

#
# User created zones
class Zone
  include Mongoid::Document

  field :gid,    type: Integer  # geonames id
  field :slug,   type: String
  field :name,   type: String,  localize: true
  field :abbr,   type: String
  field :kind,   type: String

  has_many :zone_members, dependent: :destroy

  scope :ordered, order_by(name: 1)

  validates :name, presence: true, uniqueness: true

  def members
    zone_members.map(&:member)
  end

  def to_s
    name
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geopolitical-0.8.2 app/models/zone.rb