Search code examples
ruby-on-railsrails-geocoder

where does geocoded find a user's ip address


To begin, sorry for the newbie question. I'm adding the geocoder gem to my app, and would like to query based on User ip_address. I've added latitude and longitude columns to the User database, but do I need to add ip_address to the User database as well? If so, is this a number or string or something else? If not, how will the app know where and how to find the user's IP address?


Solution

  • The users IP address is sent as part of the request header with all http requests.

    you can get if from request.remote_ip in rails

    see Rails: Get Client IP address