JMM
JMM

Reputation: 53

Newbie Rails Geocoder reverse search undefined error (Fresh project)

I have created a fresh rails project. It's running on the lastest rails version as i have just installed rails on my pc and it is using Postgre for the DB. I have added the gem 'geocoder' in the gemfile and bundle install it. I have create a scaffold rails g scaffold location address:string latitude:float longtiude:float

I have added the following code into the location model file which I got from the official geocoder website http://www.rubygeocoder.com/

reverse_geocoded_by :latitude, :longitude,
  :address => :location
after_validation :reverse_geocode

I then tried testing it, however it doesn't work. I have tried looking and reading the documentation but couldn't find any useful information. Could someone help pls.

I am getting the error of undefined method `location ....' when trying to save. This error is shown in the def create function

Parameters:

{"authenticity_token"=>"[FILTERED]", "location"=>{"address"=>"", "latitude"=>"48.8582", "longitude"=>"2.2945"}, "commit"=>"Create Location"}

Upvotes: 0

Views: 26

Answers (0)

Related Questions