I hear about and try to implement those libraries mongoid-geospatial
But they all mention this class Point
which is undefined for me. What am I missing ?
I am adding a geo concern to my models with ActiveSupport::Concern
module Mappable
extend ActiveSupport::Concern
included do
include Mongoid::Geospatial
field :coordinates, type: Point, spatial: true
spatial_scope :coordinates
uninitialized constant Mappable::Point (NameError)
You need to resolve it from the proper namespace .
field :coordinates, type: ::Mongoid::Geospatial::Point, spatial: true
The example from the docs works since they are declaring a class which does not create a new module nesting. In your case however Ruby will try to resolve Point
from the current module ( Mapping
) even if you have included Mongoid::Geospatial
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.