Problem
90% sure it's a setup error on my end, but I can't do self.factory and trying to access lonlat gives me an exception "undefined method `point' for nil:NilClass"
I can
Set lonlat using:
mfactory = RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(:geo_type => 'point')
self.lonlat = mfactory.point(long, lat)
self.save
This gives me values like 0101000020E610000061C3D32B65965DC03657CD7344F64040
in the db.
I can't use:
self.lonlat = "POINT(#{long},#{lat})"
self.save
Questions
Do I need to setup something specific in the model?
I created a github issue with a less consise but more detailed explaination.
RGeos depends on GEOS. This error is a result of RGeos not being able to load GEOS.
To check if this is the issue:
To check if you have GEOS installed:
If GEOS isn't installed:
If GEOS is installed, fix your installed RGeo:
Should now be installed correctly and your errors fixed. You can check as we did above:
If this doesn't work uninstall ALL versions of geos and rgeo:
Re-install geos and rgeo as instructed above. You should have gem 'rgeo' in your Gemfile and after you bundle, you should see this as one of the outputs: "Installing rgeo 0.4.0 with native extensions"