Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
553 views
in Technique[技术] by (71.8m points)

geolocation - 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"}

question from:https://stackoverflow.com/questions/65951532/newbie-rails-geocoder-reverse-search-undefined-error-fresh-project

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...