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?
Asked
Active
Viewed 926 times
1 Answers
0
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

Community
- 1
- 1

Ian Kenney
- 6,376
- 1
- 25
- 44
-
Hey Ian, thanks for the quick response. Is this a new method then that goes in the users_controller, or does it go in the User model? – Oct 05 '14 at 19:54
-
the request object is already available in a rails application see http://api.rubyonrails.org/classes/ActionDispatch/Request.html – Ian Kenney Oct 06 '14 at 08:07
-
This is great. So seems like i should just be able to define a new method in my users_controller, and then display users in my index by calling that method. Thanks Ian! – Oct 06 '14 at 15:52