2

I have made an account on GeoNames enabled free webservrices to use gem 'timezone' (about a day ago). When I go to http://www.geonames.org/enablefreewebservice it says

 The account my_user_name has been successfully enabled to use the free webservices.

When I put the following in the address bar and click enter it works, too

http://api.geonames.org/findNearbyPostalCodes?lat=47&lng=9&username=my_user_name

However when I run the following in my Rail4 application console

Timezone::Configure.begin do |c|
  c.username = 'xxxx'
end
timezone = Timezone::Zone.new :latlon => [-34.92771808058, 138.477041423321]

I get the error message:

 Timezone::Error::NilZone: No zone was found. Please specify a zone.

This is my first time using GeoNames so I'm not over the limit. How may I go about fixing this? One thing I noticed, require 'timezone' returns false in console.

Thanks.

user2725109
  • 2,286
  • 4
  • 27
  • 46

1 Answers1

0

I suspect your username config is probably undefined. Open the console up and check

Timezone::Configure.username

If it's nil, you've found your problem!

Try placing your config code inside an initializer, instead of application.rb. Try creating the file config/initializers/timezone.rb and place the code there.

Timezone::Configure.begin do |c|
  c.username = 'xxxx'
end

Fire up the console after that and check the username again. If it's now defined your request should now work!