0

I have an x users with their last_sign_in_ip, can i get their location details using their ip_address with rake task? I am using rails and geocoder gem.

Vishnu S
  • 13
  • 3

2 Answers2

0

Since you have the geocoder gem, use this:

Geocoder.search(user.last_sign_in_ip)

It will return a json with the address elements.

Graham Slick
  • 6,692
  • 9
  • 51
  • 87
0

please use search method from Geocoder see below code

Geocoder.search(ip)

In your case

location = Geocoder.search(last_sign_in_ip)

And from location you will get all the address details.

Amol Udage
  • 2,917
  • 19
  • 27
  • How is your answer bringing more information than the one I've posted ? Plus, last_sign_in_ip probably applies to a user so this won't work – Graham Slick May 26 '16 at 11:58