October 21

0 comments

Ruby on Rails – Get the IP and Browser of a user

By Christopher Mendla

October 21, 2016


Last Updated on November 30, 2019 by Christopher G Mendla

If you need to get the IP of a user, you can  simply use request.remote.ip

           ip = request.remote_ip


If you need to get the user browser, you can use the following
          user_browser request.env[‘HTTP_USER_AGENT’


Of course, the results would be stored in ip and user_browser respectively. 

Christopher Mendla

About the author

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}