未初始化的常量Gmaps4rails :: ActsAsGmappable

时间:2014-02-11 08:21:15

标签: ruby-on-rails ruby-on-rails-4 mongoid gmaps4rails

我根据README设置了所有内容,这是我的模型

class Building
  include Gmaps4rails::ActsAsGmappable
  include Mongoid::Document
  include Geocoder::Model::Mongoid

  acts_as_gmappable :lat => 'location[0]', :lng => 'location[1]',
                  :address => "address", :normalized_address => "full_address",
                  :msg => "Sorry, not even Google could figure out where that is"
  field :gmaps,              :type => Boolean

  field :address,            :type => String, :default => ""            
  field :city,               :type => String, :default => ""
  field :province,           :type => String, :default => ""
  field :country,            :type => String, :default => ""
  field :postal_code,        :type => Integer
  field :location,           :type => Array, spacial: {lat: :latitude, lng: :longitude, return_array: true }

  ## Building index
  index({location: "2d"})

  def full_address
    "#{address}, #{city}, #{province}, #{country}, #{postal_code}"
  end

  def gmaps4rails_address
    full_address
  end
end

控制器

@hash = Gmaps4rails.build_markers(@building) do |building, marker|
  marker.lat building.location[0]
  marker.lng building.location[1]
end

和视图

= gmaps4rails( "markers" => { "data" => @hash.to_json, "options" => { "draggable" => true }})

当我访问控件时,给我“未初始化的常量Gmaps4rails :: ActsAsGmappable”

1 个答案:

答案 0 :(得分:1)

There is not在gem中定义的ActsAsGmappable模块/类,因此出错。

似乎它已在较新版本的gem中删除。尝试删除该行,看看是否一切正常。