I want to grab the visitors IP address and use it in my controller so that I can use geocoder to find nearby objects.
So I have a Location model, and I want to run a query like this:
def index
@json = Location.near('visitor location here', 20).to_gmaps4rails
end
So I can show them a map pre-populated with the closest locations.
How do I access their IP address and use it in the controller? Can it be done? Should I be trying to accomplish this in the model using a scope?
From your controller:
request.remote_ip