2017-01-02 5 views
0

내가 듣고 그 라이브러리

mongoid-geospatial을 구현하려고 초기화되지 않은 일정 포인트를 mongoid하지만 그들은 모두 나를 위해 정의되지 않는다이 클래스 Point을 언급. 내가 뭘 놓치고 있니?

나는 당신은 proper namespace에서 그것을 해결해야 ActiveSupport :: 우려

module Mappable 
    extend ActiveSupport::Concern 

    included do 
    include Mongoid::Geospatial 

    field :coordinates, type: Point, spatial: true 
    spatial_scope :coordinates 

초기화되지 않은 일정하게 매핑 :: 포인트 (나가서 설명하자면 NameError)

답변

2

내 모델 지리적 우려를 추가하고 .

field :coordinates, type: ::Mongoid::Geospatial::Point, spatial: true 

docs의 예제는 새 모듈 중첩을 만들지 않는 클래스를 선언하기 때문에 작동합니다. 귀하의 경우, Ruby는 Mongoid::Geospatial을 포함하더라도 현재 모듈 (Mapping)에서 Point을 해결하려고합니다.