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

Categories

0 votes
616 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...