Get current position via geocoder. Rails

rails-geocoder, ruby-on-rails, ruby-on-rails-4

Solution

This is because in development environment your ip address is 127.0.0.1 which is not a real Internet ip address. This will work return latitude and longitude for an Internet ip.

You can configure ip address in development environment, to do this add following lines in app/config/environment/development.rb

class ActionDispatch::Request
    def ip
      "216.52.207.74"
    end
end

Restart your server and now it should return valid latitude and longitude

Problem

I'm trying to get current coordinates using geocoder. But ``` request.location.latitude request.location.longitude ``` always returns 0.0 and 0.0 for me. Is it possible to find geolocation coordinates using geocoder? Thanks in advance!

Original source