I have a very low traffic web site and I want to record the IP address of everyone who visits it.
I know Ruby geocoder can detect IP of whoever's making a request
request.ip # => "216.232.140.27"
However, I'm not sure how I can record this to a database or somehow store it so I can see it if someone just visits my website.
i.e my problem/mental blockage seems to be that I expect someone to click a button in order to trigger a method but I want the IP address stored by someone just visiting....
Can someone explain how I could write a method to store the IP address in a database (or somewhere other than a database such as the logs if that's better) if someone merely visits my site?
If I understand correctly what you need, then you dig in the wrong direction.
First, ip
method is contained in a standard request
, it is not relevant to the Geocoder: http://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-ip
Second, much easier to install third-party statistics in order then keep track of all visitors (by ip or whatever you want). For example: http://www.google.com/analytics/
Hope this helps.