Sha256: b6469385f28787f7fffb3d690eebc325f865fb3685317de778e165f2550f9f78
Contents?: true
Size: 998 Bytes
Versions: 1
Compression:
Stored size: 998 Bytes
Contents
# # Cities # class City include Mongoid::Document include Mongoid::Geospatial include GeoHelper field :gid, type: Integer field :zip, type: String field :slug, type: String field :name, type: String, localize: true field :ascii, type: String field :area, type: Integer field :souls, type: Integer field :geom, type: Point, spatial: true spatial_scope :geom attr_writer :x, :y, :z belongs_to :region belongs_to :nation has_many :hoods index name: 1 scope :ordered, -> { order_by(name: 1) } validates :slug, presence: true, uniqueness: true validates :name, uniqueness: { scope: :region_id } # scope :close_to, GeoHelper::CLOSE before_validation :set_defaults def set_defaults self.nation ||= region.try(:nation) end def abbr return unless region || nation region ? region.abbr : nation.abbr end def self.search(txt) where(slug: /#{txt}/i) end def <=>(other) slug <=> other.slug end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geopolitical-0.8.3 | app/models/city.rb |