How to get browser, operating system and client ip in rails

    You can do by adding these function in your controller or you can specify these as helper methods
    def get_browser
          if request.env['HTTP_USER_AGENT'].downcase.match(/crome/i)
            "Crome"
          elsif request.env['HTTP_USER_AGENT'].downcase.match(/msie/i)
            "Internet Explorer"
         elsif request.env['HTTP_USER_AGENT'].downcase.match(/konqueror/i)
            "Konqueror"
         elsif request.env['HTTP_USER_AGENT'].downcase.match(/firefox/i)
            "Mozilla"
         elsif request.env['HTTP_USER_AGENT'].downcase.match(/opera/i)
            "Opera"
         elsif request.env['HTTP_USER_AGENT'].downcase.match(/safari/i)
            "Safari"
          else
            "Unknown"
          end
        end
     
        def get_operating_system
          if request.env['HTTP_USER_AGENT'].downcase.match(/mac/i)
            "Mac"
          elsif request.env['HTTP_USER_AGENT'].downcase.match(/windows/i)
            "Windows"
          elsif request.env['HTTP_USER_AGENT'].downcase.match(/linux/i)
            "Linux"
          elsif request.env['HTTP_USER_AGENT'].downcase.match(/unix/i)
            "Unix"
          else
            "Unknown"
          end
        end
        def client_ip
          request.remote_ip
        end


    # You can simply call there by there name

    get_operating_system like this
    5
    Average: 5 (1 vote)

    User login