How to get ip address, referer, and user agent in ruby?
问题 I want to log user's ip address, referer, and user agent. In PHP, I can get them from the following variables: $_SERVER['REMOTE_ADDR'] $_SERVER['HTTP_REFERER'] $_SERVER['HTTP_USER_AGENT'] How to get them in ruby? 回答1: You need the array request.env request.env['REMOTE_ADDR']: 回答2: PHP is embedded in a web server. Ruby is a general-purpose language: if you need a web server context, you'll have to install it yourself. Fortunately, it's easy. One of the easiest ways to get started is with