Sha256: b6b5f8e5cbc8bec1d935056296c4823989ed00eee0544060ebb3fb4fa703f21a

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

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

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

  field :active, type: Mongoid::Boolean

  has_many :members, class_name: "Zone::Member", dependent: :destroy

  scope :ordered,  -> { order_by(name: 1) }
  scope :active,   -> { where(active: true) }

  # validates :name, presence: true# , uniqueness: true

  def to_s
    name
  end

  def self.icon
    "globe"
  end

  # Zone::Member
  class Member
    include Mongoid::Document

    belongs_to :zone
    belongs_to :member, polymorphic: true
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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