I tried the example on http://www.tbcn.ca/ruby_geonames to try and get the country subdivision for a given set of coordinates:
country_subdivision = Geonames::WebService.country_subdivision 3.900120387, -78.882869834
This results in the following error:
NoMethodError: undefined method `country_code=' for
<CountrySubdivision:0x2b61bf76bf50>
from
/home/sjors/afstuderen/demo/vendor/rails/activerecord/lib/active_record/base.rb:1860:in
method_missing'
from
/var/lib/gems/1.8/gems/geonames-0.2.1/lib/web_service.rb:377:in
country_subdivision'
from /usr/lib/ruby/1.8/rexml/element.rb:934:in each'
from /usr/lib/ruby/1.8/rexml/xpath.rb:53:in
each'
from /usr/lib/ruby/1.8/rexml/element.rb:934:in each'
from
/var/lib/gems/1.8/gems/geonames-0.2.1/lib/web_service.rb:376:in
country_subdivision'
from (irb):2
All the other examples on the site work fine.
What version of the product are you using? On what operating system?
Im am using the geonames Gem 0.2.1 on Ubuntu: Linux 2.6.22-14-generic #1 SMP Sun Oct 14 21:45:15 GMT 2007 x86_64 Rails: 1.2.5 Ruby: 1.8.6
Please provide any additional information below. I would very much like to use the country subdivision feature.
Comment #1
Posted on Nov 27, 2007 by Helpful Rhinois this still a problem? I am not able to reproduce it on OS X (ruby 1.8.6) and CentOS (ruby 1.8.5)
Comment #2
Posted on Nov 27, 2007 by Helpful LionYet it is, though only on 2 out of 3 computers. I tried it on two other machines:
2) * Ubuntu: Linux PC07-PDIC104 2.6.20-16-generic #2 SMP Sun Sep 23 19:50:39 UTC 2007 i686 GNU/Linux * ruby 1.8.6
Same problem.
3) * Debian: Linux 2.4.27-2-386 #1 Wed Aug 17 09:33:35 UTC 2005 i686 GNU/Linux * ruby 1.8.5 (2006-08-25) [i486-linux]
Works fine.
By the way, if I use the example coordinates (and remove the line break), I get an 'empty' response and no error message:
country_subdivision = Geonames::WebService.country_subdivision 3.900120387,-78.882869834 => #
So I also tried my own city:
country_subdivision = Geonames::WebService.country_subdivision 52.09277,5.12435 => #
This works on machine 3),not on 1) and 2)
So perhaps Ubuntu is the key here?
Comment #3
Posted on Jan 28, 2008 by Helpful LionI just upgraded to version 0.2.2., but that does not resolve the issue unfortunately.
Comment #4
Posted on Feb 5, 2008 by Helpful LionI think I found out what might be causing the problem. On of my database tables is called "country_subdivisions" and so the name CountrySubdivision is already in use in my rails environment. That might explain why Geonames::WebService.timezone does not cause any problems, although their ruby code seems to be similar.
I am not sure what I am doing wrong with my naming conventions.
Also, the big difference between machines 1,2 and machine 3 is that the latter is a rails production environment.
Comment #5
Posted on Feb 7, 2008 by Helpful LionActually the crucial problem seems to be the filename 'country_subdivision.rb'. Rails ignores this file, probably because it already included the 'country_subdivision.rb' that defines CountrySubdivision from active record. I can 'fix' the problem by renaming 'country_subdivision.rb' to 'country_subdivision2.rb'.
Comment #6
Posted on Mar 4, 2008 by Helpful Rhinothanks for posting your "fix" :) not sure what I can do at this point to fix this for others that might run into it.. I'll do some debugging later.
Comment #7
Posted on Mar 4, 2008 by Helpful Rhino(No comment was entered for this change.)
Status: WontFix
Labels:
Type-Defect
Priority-Medium