문제

Why wouldn't

Location.where(address: nil).each do |location|
    location.reverse_geocode
    location.save!
end

work, while

class Location < ActiveRecord::Base
    reverse_geocoded_by :latitude, :longitude
    after_validation :reverse_geocode
end

reverse geocodes any new locations? The console doesn't error, it just returns the activerecord relation with the address values still nil.

도움이 되었습니까?

해결책 2

So my original solution worked, I just had to restart my machine. Strangely, restarting the console, server, and editor did nothing, so I suspect some dark magic is going on with RVM.

Thanks for the help, everyone.

다른 팁

try with this

location.address = location.reverse_geocode
location.save!
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top