Last Updated: February 25, 2016
·
1.087K
· dcdieci

rgeo upgrade to 0.3.20 in rails 4.2.2 -NoMethodError: undefined method `point' for

I just updated my rails application to 4.2.2 and therefore I did also update the rgeo gem to 0.3.20

I ran in the following error:

NoMethodError: undefined method `point' for nil:NilClass
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/rgeo-0.3.20/lib/rgeo/wkrep/wkb_parser.rb:227:in `_parse_object'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/rgeo-0.3.20/lib/rgeo/wkrep/wkb_parser.rb:158:in `parse'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.0.0/lib/active_record/connection_adapters/postgis/oid/spatial.rb:102:in `parse_wkt'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.0.0/lib/active_record/connection_adapters/postgis/oid/spatial.rb:90:in `type_cast'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/type/value.rb:23:in `type_cast_from_database'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/attribute.rb:104:in `type_cast'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/attribute.rb:42:in `original_value'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/attribute.rb:37:in `value'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/attribute_set.rb:31:in `fetch_value'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/attribute_methods/read.rb:93:in `_read_attribute'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/attribute_methods/read.rb:87:in `read_attribute'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/attribute_methods.rb:305:in `attribute_for_inspect'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/core.rb:444:in `block in inspect'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/core.rb:442:in `collect'
from /Users/dc/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.2/lib/active_record/core.rb:442:in `inspect'
from (irb):4

So I digged into the rgeo lib and noticed that the factory generator in rgeo returned nil in rgeo/geos/interface.rb

You can check it in irb

2.2.1 :001 > require 'rgeo'
 => true 
2.2.1 :002 > RGeo::Geos.supported?
 => false 

So you wanna make sure that you have the GEOS lib installed. I solved it via brew brew install geos and installed rgeo again and finally it worked