Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 43 lines (36 sloc) 0.91 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
require 'rubygems'
require 'test/unit'
require 'test_helper'
require 'mongoid'
require 'geocoder/models/mongoid'

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

if (::Mongoid::VERSION >= "3")
  Mongoid.logger = Logger.new($stderr, :debug)
else
  Mongoid.configure do |config|
    config.logger = Logger.new($stderr, :debug)
  end
end

##
# Geocoded model.
#
class Place
  include Mongoid::Document
  include Geocoder::Model::Mongoid

  geocoded_by :address, :coordinates => :location
  field :name
  field :address
  field :location, :type => Array

  def initialize(name, address)
    super()
    write_attribute :name, name
    write_attribute :address, address
  end
end

class PlaceWithoutIndex
  include Mongoid::Document
  include Geocoder::Model::Mongoid

  field :location, :type => Array
  geocoded_by :location, :skip_index => true
end
Something went wrong with that request. Please try again.