Is there a way to add a column in the session table (using MySQL) to record the requester''s IP address? Or possibly extend the session code to write to another table or log file that I could use to correlate session and requester IP address. I need this short term for a debugging task. -- gw -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Stephan Wehner
2008-Apr-12 08:34 UTC
Re: Possible to add request IP column in session table ??
The easiest way may be to add a "before_filter",
class ApplicationController < ActionController::Base
before_filter :save_request_ip
def save_request_ip
session[:request_ip] = request.remote_ip
end
protected :save_request_ip
# :
# :
# rest of your ApplicationController code
# :
# :
end
Then read back the value from session[:request_ip] as needed.
The requester''s IP may change from request to request, if they have
IP''s assigned dynamically, for example. Not quite clear how this would
be a "short term debugging requirement". Also may require browser has
"cookies enabled", depending on what you''re up to.
Stephan
On Apr 11, 4:25 pm, Greg Willits
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Is there a way to add a column in the session table (using MySQL) to
> record the requester''s IP address?
>
> Or possibly extend the session code to write to another table or log
> file that I could use to correlate session and requester IP address.
>
> I need this short term for a debugging task.
>
> -- gw
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---