Geokit Rails issue

I'm getting undefined local variable or method `acts_as_mappable'.

I only have 1 model in my app right now. I have tried several methods of installation.

1. Tried using bundler adding gem "geokit", "1.5.0" to the Gemfile and bundle install and bundle pack.

2. Tried Rails::Initializer.run do |config|config.gem "geokit" end with rake gems:install

3. tried ./script/plugin install git://github.com/andre/geokit-rails.git

none of these work for me. I get the same error.

Here is my model.

require 'geokit' require 'vendor/plugins/geokit-rails/init.rb' class Listing < ActiveRecord::Base   acts_as_mappable end

got my config/preinitializer.rb file

Any ideas?

~Jeremy Woertink

I'm getting undefined local variable or method `acts_as_mappable'.

I only have 1 model in my app right now. I have tried several methods of installation.

1. Tried using bundler adding gem "geokit", "1.5.0" to the Gemfile and bundle install and bundle pack.

2. Tried Rails::Initializer.run do |config|config.gem "geokit" end with rake gems:install

3. tried ./script/plugin install git://github.com/andre/geokit-rails.git

none of these work for me. I get the same error.

Here is my model.

require 'geokit' require 'vendor/plugins/geokit-rails/init.rb' class Listing < ActiveRecord::Base   acts_as_mappable end

got my config/preinitializer.rb file

Any ideas?

Craig White wrote:

Craig White wrote: >> >> end >> >> got my config/preinitializer.rb file >> >> Any ideas? > ---- > It doesn't stick out in my mind so I have to believe that somewhere in > their documentation, you just add to config/environment.rb (inside the > initializer loop) > > config.gem "geokit" > > Craig > yeah, I tried that, and it didn't work. (see method #2). I've already done a google search for that error, and a couple blogs come up that show methods for fixing it. I've tried their methods, but it hasn't worked for me.

Craig White wrote: >> >> end >> >> got my config/preinitializer.rb file >> >> Any ideas? > ---- > It doesn't stick out in my mind so I have to believe that somewhere in > their documentation, you just add to config/environment.rb (inside the > initializer loop) > > config.gem "geokit" >

yeah, I tried that, and it didn't work. (see method #2). I've already done a google search for that error, and a couple blogs come up that show methods for fixing it. I've tried their methods, but it hasn't worked for me.

Craig White wrote:

> their documentation, you just add to config/environment.rb (inside the > initializer loop) > > config.gem "geokit" > > Craig > yeah, I tried that, and it didn't work. (see method #2). I've already done a google search for that error, and a couple blogs come up that show methods for fixing it. I've tried their methods, but it hasn't worked for me.

---- umm... of course it works - I have a fully functional web site working using exactly that setup. That also is the way to tell rails to use an installed gem in the application.

Craig

-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.

yeah, I got all the other gems working fine. (rails, mysql, paperclip, will_paginate, clearance). Just for some reason, I can't get this one to work. Actually, I take that back. If I hop into console and require "geokit", then I can use the API directly. The only thing I can't get to work is acts_as_mappable. It just keeps saying that it's undefined. My model is Listing, so when I just hop into console and type "Listing" it throws the error, even if I require 'geokit' first.

Craig White wrote: >> > their documentation, you just add to config/environment.rb (inside the >> > initializer loop) >> > >> > config.gem "geokit" >> > >> > Craig >> > >> yeah, I tried that, and it didn't work. (see method #2). I've already >> done a google search for that error, and a couple blogs come up that >> show methods for fixing it. I've tried their methods, but it hasn't >> worked for me. > ---- > umm... of course it works - I have a fully functional web site working > using exactly that setup. That also is the way to tell rails to use an > installed gem in the application. > > Craig > > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean.

yeah, I got all the other gems working fine. (rails, mysql, paperclip, will_paginate, clearance). Just for some reason, I can't get this one to work. Actually, I take that back. If I hop into console and require "geokit", then I can use the API directly. The only thing I can't get to work is acts_as_mappable. It just keeps saying that it's undefined. My model is Listing, so when I just hop into console and type "Listing" it throws the error, even if I require 'geokit' first.

Craig White wrote:

>> done a google search for that error, and a couple blogs come up that > -- model is Listing, so when I just hop into console and type "Listing" it throws the error, even if I require 'geokit' first.

---- I don't use the plugin, don't use any 'require' anything just...

config/environment.rb

  config.gem "geokit" ' and in my model...

  acts_as_mappable

that's it - nothing more... restart the web server, open a console - done.

Craig

-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.

hmm, yeah. It's the weirdest thing. I started a fresh app and tried just that, and it was a no go. I still get undefined method acts_as_mappable.... I'm not sure what's going on, but that's for the help :slight_smile:

using: Ruby 1.8.7 Rails 2.3.5 Geokit 1.5.0 OSX 10.5.8

Jeremy Woertink wrote in post #892229:

hmm, yeah. It's the weirdest thing. I started a fresh app and tried just that, and it was a no go. I still get undefined method acts_as_mappable.... I'm not sure what's going on, but that's for the help :slight_smile:

using: Ruby 1.8.7 Rails 2.3.5 Geokit 1.5.0 OSX 10.5.8

Did you ever get anywhere on this issue? Were you using Bundler at the time? I just ran into it while setting up an existing application to use Bundler. Upon disabling Bundler, everything works as before, so I'm certain it's a Bundler bug... Not sure where to start on it.

Corey W. wrote in post #983408:

Jeremy Woertink wrote in post #892229:

hmm, yeah. It's the weirdest thing. I started a fresh app and tried just that, and it was a no go. I still get undefined method acts_as_mappable.... I'm not sure what's going on, but that's for the help :slight_smile:

using: Ruby 1.8.7 Rails 2.3.5 Geokit 1.5.0 OSX 10.5.8

Did you ever get anywhere on this issue? Were you using Bundler at the time? I just ran into it while setting up an existing application to use Bundler. Upon disabling Bundler, everything works as before, so I'm certain it's a Bundler bug... Not sure where to start on it.

Solved it! First, make sure you don't have the geokit-rails plugin installed. It just confuses Bundler and Rails. Then make sure you specify in your Gemfile BOTH the geokit gem AND the geokit-rails gem, something like this:

gem 'geokit', '>= 1.5.0' gem 'geokit-rails', '1.1.4'

If you're on Rails 3, that should do it. If you're on Rails 2 like me, you'll need to make sure you follow the instructions on the Bundler website: Gem Bundler – Manage your Ruby gems

Works beautifully for me!