# Capture IP Address to Sessions

**URL:** <https://www.ruby-forum.com/t/capture-ip-address-to-sessions/121040>\
**Category:** Rails\
**Created:** [November 23, 2007, 3:29am UTC](https://www.ruby-forum.com/t/capture-ip-address-to-sessions/121040 "2007-11-23T03:29:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrLipid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@MrLipid](https://www.ruby-forum.com/u/MrLipid)\
**Post date:** [November 23, 2007, 3:29am UTC](https://www.ruby-forum.com/t/capture-ip-address-to-sessions/121040/1 "2007-11-23T03:29:49Z")

</div>

What I’d like to do:

Capture the IP addresses of the folks visiting a web site in the  
Sessions table.

What needs to be in place (code, model, controller, etc.), where does  
it need to go (application controller?), how best to set up the  
Sessions table?

Appreciate a noob-friendly outline of what needs to be done.

Thanks.

---

<div class="post-metadata">

**Author:** ![MrLipid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@MrLipid](https://www.ruby-forum.com/u/MrLipid)\
**Post date:** [November 23, 2007, 4:41am UTC](https://www.ruby-forum.com/t/capture-ip-address-to-sessions/121040/2 "2007-11-23T04:41:45Z")

</div>

On Nov 22, 2007, at 6:29 PM, MrLipid wrote:

> What I’d like to do:
> 
> Capture the IP addresses of the folks visiting a web site in the  
> Sessions table.
> 
> What needs to be in place (code, model, controller, etc.), where does  
> it need to go (application controller?), how best to set up the  
> Sessions table?
> 
> Appreciate a noob-friendly outline of what needs to be done.

The ip address is available from request.remote\_ip, as in:

login\_terminal = request.remote\_ip

don’t know how to extend the sessions schema though (I log it  
separately from sessions)

– gw (www.railsdev.ws)

---

<div class="post-metadata">

**Author:** ![MrLipid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@MrLipid](https://www.ruby-forum.com/u/MrLipid)\
**Post date:** [November 23, 2007, 4:51am UTC](https://www.ruby-forum.com/t/capture-ip-address-to-sessions/121040/3 "2007-11-23T04:51:41Z")

</div>

On Nov 22, 9:41 pm, Greg W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Appreciate a noob-friendly outline of what needs to be done.
> 
> The ip address is available from request.remote\_ip, as in:
> 
> login\_terminal = request.remote\_ip
> 
> don’t know how to extend the sessions schema though (I log it  
> separately from sessions)
> 
> – gw (www.railsdev.ws)

Appreciate the prompt response.

Maybe I should have capitalized Noob. 😉

Where would " login\_terminal = request.remote\_ip" go? Does it belong  
in a controller? Are there any other elements that must be present?  
Models, helpers, etc.?

Where do you put the IP information that this yields? (I assumed it  
could go in Sessions but have no need for it to go there.)
