Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Rails, how do I access the Request.ServerVariables like you do in ASP?

I want to access a given Requests ServerVariables, but I can't seem to find anything on Google on how to get access to the Server Vars of the request object. How do I do this or am I doomed to simply never know?

An example of why I'd want to do this (but not actually what I want to do):
User logs in, and you want to store the IP address of place where they logged in, or perhaps I want to record the user-agent or referer from the browser that they are viewing the site.

like image 571
Ash Avatar asked Dec 08 '25 12:12

Ash


1 Answers

You should look at the request object that's available from the controller. There are a bunch of methods like

request.remote_ip

you can read more about the Request object on the Rails API site

like image 52
Scott Avatar answered Dec 10 '25 05:12

Scott