本文介绍了Rails 3.1.0,geokit,错误为acts_as_mappable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了

undefined local variable or method `acts_as_mappable'

使用 geokit 时出错,经过大量的 Goggling 和尝试,我似乎无法纠正问题.

error when using geokit, and after tons of Goggling and attempts, I cannot seem to be able correct the problem.

基本上,我安装了以下 gem:

Basically, I have the following gems installed:

geokit (1.6.0, 1.5.0)
geokit-rails31 (0.1.3)

并在我的模型中包含以下内容

and have the following in my model

class House < ActiveRecord::Base
  acts_as_mappable
end

和 Gemfile:

gem 'geokit', '>= 1.5.0'
gem 'geokit-rails31'

无论是否在本地应用中执行以下操作,我都会收到错误消息.

I get the error with or without doing the following in my local app.

rails plugin install git://github.com/jlecour/geokit-rails3.git

推荐答案

好的 - 这里是任何需要帮助的人的解决方案......

Okay - Here is the solution for anyone that needs help on how I got it to work...

确保您的项目 Gemfile 不包含任何类型的 geokit 信息.

Make sure your project Gemfile does not contain any geokit info of any kind.

安装 geokit

> gem install geokit

> gem list geo
*** LOCAL GEMS ***
geokit (1.6.0, 1.5.0)

卸载 geokit-rails3 和 geokit-rails31

uninstall geokit-rails3 and geokit-rails31

> gem uninstall geokit-rails31 geokit-rails3

在您的项目中,在根级别:

in your project, at the root level:

> rails plugin install git://github.com/jlecour/geokit-rails3.git

编辑规范

> vi vendor/plugins/geokit-rails3/geokit-rails3.gemspec

将 rails 依赖行更改为

change rails dependency line to be

s.add_runtime_dependency 'rails', '>= 3.1.0'

现在,编辑 Gemfile 以包含 gem

now, edit the Gemfile to include the gem

gem 'geokit-rails3', :path => 'vendor/plugins/geokit-rails3'

注意,Gemfile 只包含 geokit-rails3 的条目,没有普通 geokit gem 的条目.即没有gem 'geokit', '>= 1.5.0'"条目

Note, the Gemfile only contains an entry for the geokit-rails3, and no entries for normal geokit gem. i.e. there is not a "gem 'geokit', '>= 1.5.0'" entry

然后在您的应用程序根目录中执行

then in your application root, do a

bundle install

应该已经设置好了,您现在可以按照典型教程进行操作 - 如 git 说明中所述

It should be setup, and you can now follow a typical tutorial - as described in the git instructions

https://github.com/jlecour/geokit-rails3

这篇关于Rails 3.1.0,geokit,错误为acts_as_mappable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 23:38