Sha256: c614c1ee37ec7723cdc5b530a34b9fa83d1252d14a2b337d6f254bf4d7654e08
Contents?: true
Size: 971 Bytes
Versions: 1
Compression:
Stored size: 971 Bytes
Contents
class City include Mongoid::Document include Mongoid::Geospatial include Geopolitical::Helpers field :gid, type: Integer field :zip, type: String field :slug, type: String field :name, type: String, localize: true field :area, type: Integer field :souls, type: Integer field :geom, type: Point, spatial: true # field :ascii, type: String 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 region ? region.abbr : nation.abbr end def self.search txt where(slug: /#{txt}/i) end def <=> other self.slug <=> other.slug end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geopolitical-0.8.1 | app/models/city.rb |