# Geokit Plugin On Hosted Server

**URL:** <https://www.ruby-forum.com/t/geokit-plugin-on-hosted-server/192960>\
**Category:** Rails\
**Created:** [August 9, 2010, 7:23am UTC](https://www.ruby-forum.com/t/geokit-plugin-on-hosted-server/192960 "2010-08-09T07:23:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![globalxolutions](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e480ec/32.png) [@globalxolutions](https://www.ruby-forum.com/u/globalxolutions)\
**Post date:** [August 9, 2010, 7:23am UTC](https://www.ruby-forum.com/t/geokit-plugin-on-hosted-server/192960/1 "2010-08-09T07:23:05Z")

</div>

Hi, I am new here, but I hope somebody have a clue about this issue.

I am using rails 2.2.2 and the geokit gem. It works very good for a  
while, but for unknown reason it stopped working on my hosting server,  
but it still working alright on my developer machine.

Here it is what I got on script/console

-bash-3.2$ script/console production  
Loading production environment (Rails 2.2.2)

> > include Geokit::Geocoders  
> > =\> Object
> 
> > res = GoogleGeocoder.geocode ‘New York’  
> > =\> #\<Geokit::GeoLoc:0x2b6512375df0 @zip=nil, @precision=“unknown”,  
> > @all=[#\<Geokit::GeoLoc:0x2b6512375df0 …\>], @lng=nil, @success=false,  
> > @state=nil, @lat=nil, @province=nil, @city=nil, @country\_code=nil,  
> > @street\_address=nil, @full\_address=nil\>

But, on my local machine:

script/console production  
Loading production environment (Rails 2.2.2)

> > include Geokit::Geocoders  
> > =\> Object
> 
> > res = GoogleGeocoder.geocode ‘New York’  
> > =\> #\<Geokit::GeoLoc:0x1a25890 @country=“USA”, @city=“New York”,  
> > @suggested\_bounds=#\<Geokit::Bounds:0x19272f4  
> > @ne=#\<Geokit::LatLng:0x19270c4 @lng=-73.7498543, @lat=40.8495342\>,  
> > @sw=#\<Geokit::LatLng:0x1927290 @lng=-74.2620919, @lat=40.5788964\>\>,  
> > @precision=“city”, @country\_code=“US”, @street\_address=nil, @accuracy=4,  
> > @full\_address=“New York, NY, USA”, @provider=“google”, @zip=nil,  
> > @all=[#\<Geokit::GeoLoc:0x1a25890 …\>], @lng=-74.0059731, @success=true,  
> > @state=“NY”, @lat=40.7143528, @province=“New York”\>

Any suggestion or clue ??

---

<div class="post-metadata">

**Author:** ![globalxolutions](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e480ec/32.png) [@globalxolutions](https://www.ruby-forum.com/u/globalxolutions)\
**Post date:** [August 9, 2010, 11:57am UTC](https://www.ruby-forum.com/t/geokit-plugin-on-hosted-server/192960/2 "2010-08-09T11:57:44Z")

</div>

On 9 August 2010 06:23, Ariel De la rosa [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Loading production environment (Rails 2.2.2)
> 
> @full\_address=“New York, NY, USA”, @provider=“google”, @zip=nil,  
> @all=[#\<Geokit::GeoLoc:0x1a25890 …\>], @lng=-74.0059731, @success=true,  
> @state=“NY”, @lat=40.7143528, @province=“New York”\>
> 
> Any suggestion or clue ??

I seem to remember that you have to initialise Geokit with the  
necessary information about your API keys for various geolocation  
services. It looks here like the server hasn’t got that configuration,  
so it’s not returning as many (or any) results. Is it possible your  
deployment process to the server swaps out the configuration file or  
something like that, and the one that the server ends up using doesn’t  
have the right API credentials in it?

Chris

---

<div class="post-metadata">

**Author:** ![globalxolutions](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e480ec/32.png) [@globalxolutions](https://www.ruby-forum.com/u/globalxolutions)\
**Post date:** [August 9, 2010, 4:05pm UTC](https://www.ruby-forum.com/t/geokit-plugin-on-hosted-server/192960/3 "2010-08-09T16:05:16Z")

</div>

Chris M. wrote:

> On 9 August 2010 06:23, Ariel De la rosa [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Loading production environment (Rails 2.2.2)
> > 
> > @full\_address=“New York, NY, USA”, @provider=“google”, @zip=nil,  
> > @all=[#\<Geokit::GeoLoc:0x1a25890 …\>], @lng=-74.0059731, @success=true,  
> > @state=“NY”, @lat=40.7143528, @province=“New York”\>
> > 
> > Any suggestion or clue ??
> 
> I seem to remember that you have to initialise Geokit with the  
> necessary information about your API keys for various geolocation  
> services. It looks here like the server hasn’t got that configuration,  
> so it’s not returning as many (or any) results. Is it possible your  
> deployment process to the server swaps out the configuration file or  
> something like that, and the one that the server ends up using doesn’t  
> have the right API credentials in it?
> 
> Chris

HI chris, thanks for your fast reply!

I looked at the apis key, but they seems to be working. In my config I  
have:

config/gmaps\_api\_key.yml  
development:  
A-here-is-my-api-key-for-development-environment-g

test:

production:  
ABA-here-is-my-api-key-for-production-environment-gMQ

\*\*\* EOF \*\*\*

and

config/initilializers/geokit\_config.rb

if defined? Geokit

# These defaults are used in Geokit::Mappable.distance\_to and in

acts\_as\_mappable  
Geokit::default\_units = :miles  
Geokit::default\_formula = :sphere

# This is the timeout value in seconds to be used for calls to the

geocoder web

# services. For no timeout at all, comment out the setting. The

timeout unit

# is in seconds.

Geokit::Geocoders::request\_timeout = 3

# These settings are used if web service calls must be routed through

a proxy.

# These setting can be nil if not needed, otherwise, addr and port

must be

# filled in at a minimum. If the proxy requires authentication, the

username

# and password can be provided as well.

Geokit::Geocoders::proxy\_addr = nil  
Geokit::Geocoders::proxy\_port = nil  
Geokit::Geocoders::proxy\_user = nil  
Geokit::Geocoders::proxy\_pass = nil

# This is your yahoo application key for the Yahoo Geocoder.

# See [http://developer.yahoo.com/faq/index.html#appid](http://developer.yahoo.com/faq/index.html#appid)

# and [http://developer.yahoo.com/maps/rest/V1/geocode.html](http://developer.yahoo.com/maps/rest/V1/geocode.html)

Geokit::Geocoders::yahoo = ‘REPLACE\_WITH\_YOUR\_YAHOO\_KEY’

# This is your Google Maps geocoder key.

# See [Google Maps প্ল্যাটফর্ম FAQ &nbsp;|&nbsp; Google Maps Platform &nbsp;|&nbsp; Google for Developers](http://www.google.com/apis/maps/signup.html)

# and

[http://www.google.com/apis/maps/documentation/#Geocoding\_Examples](http://www.google.com/apis/maps/documentation/#Geocoding_Examples)  
Geokit::Geocoders::google = ‘REPLACE\_WITH\_YOUR\_GOOGLE\_KEY’

# This is your username and password for [geocoder.us](http://geocoder.us).

# To use the free service, the value can be set to nil or false. For

# usage tied to an account, the value should be set to

username:password.

# See [http://geocoder.us](http://geocoder.us)

# and [http://geocoder.us/user/signup](http://geocoder.us/user/signup)

Geokit::Geocoders::geocoder\_us = false

# This is your authorization key for geocoder.ca.

# To use the free service, the value can be set to nil or false. For

# usage tied to an account, set the value to the key obtained from

# Geocoder.ca.

# See [http://geocoder.ca](http://geocoder.ca)

# and [geocoder.ca: geocoding for North America - USA and Canada](http://geocoder.ca/?register=1)

Geokit::Geocoders::geocoder\_ca = false

# Uncomment to use a username with the Geonames geocoder

#Geokit::Geocoders::geonames=“REPLACE\_WITH\_YOUR\_GEONAMES\_USERNAME”

# This is the order in which the geocoders are called in a failover

scenario

# If you only want to use a single geocoder, put a single symbol in

the array.

# Valid symbols are :google, :yahoo, :us, and :ca.

# Be aware that there are Terms of Use restrictions on how you can use

the

# various geocoders. Make sure you read up on relevant Terms of Use

for each

# geocoder you are going to use.

Geokit::Geocoders::provider\_order = [:google]

# The IP provider order. Valid symbols are :ip,:geo\_plugin.

# As before, make sure you read up on relevant Terms of Use for each

# Geokit::Geocoders::ip\_provider\_order = [:geo\_plugin,:ip]

end

I played around with both, putting the key directly on geokit\_config.rb  
and taking it out from gmaps\_api\_key.yml but, when I moved the key from  
the yml file I started to receive the google API Key Alert.

Definitely, is not the api key issue. ☹
