How to capture IP address in ruby 1.8.7

165 views
Skip to first unread message

Khan

unread,
Jun 18, 2013, 1:56:02 AM6/18/13
to rubyonra...@googlegroups.com
Hi all, I want to capture IP address in ruby 1.8.7 can any one help me out how to capture IP.



Thanks in advance

sameena Khan

unread,
Jun 18, 2013, 2:18:55 AM6/18/13
to rubyonra...@googlegroups.com
I have tried with request.remote_ip.But this works in rails not in ruby. I have to pass ip address as a parameter.


On Tue, Jun 18, 2013 at 11:26 AM, Khan <emailtosa...@gmail.com> wrote:
Hi all, I want to capture IP address in ruby 1.8.7 can any one help me out how to capture IP.



Thanks in advance

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7a0ea49a-cede-4bd1-b797-26f0b8c630c9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Rafi A

unread,
Jun 18, 2013, 2:39:26 AM6/18/13
to rubyonra...@googlegroups.com
How about using request.remote_addr ?


Regards,
Seeni Rafiyullah Khan A,



On Tue, Jun 18, 2013 at 1:56 AM, Khan <emailtosa...@gmail.com> wrote:
Hi all, I want to capture IP address in ruby 1.8.7 can any one help me out how to capture IP.



Thanks in advance

--

sameena Khan

unread,
Jun 18, 2013, 3:05:23 AM6/18/13
to rubyonra...@googlegroups.com
Thanks Rafi for your reply but can I use request.remore_addr directly like
ip = request.remote_addr in ruby. it is saying undefined request local vairable.


Loganathan Sellapa

unread,
Jun 18, 2013, 3:10:56 AM6/18/13
to Rails

Can you copy your ruby script ?

Regards,
Logan

Sent from mobile device

Rafi A

unread,
Jun 18, 2013, 3:12:04 AM6/18/13
to rubyonra...@googlegroups.com
The controller is intended to handle things related to the request and response. Are you trying this out when you are inside the model?? If so, then you can't access the request inside model.


Regards,
Seeni Rafiyullah Khan A



sameena Khan

unread,
Jun 18, 2013, 3:35:12 AM6/18/13
to rubyonra...@googlegroups.com
ip = request.remote_addr
NameError: undefined local variable or method `request' for #<Object:0xb785f950>
    from (irb):1
    from :0
Which I am getting in irb.


Rafi A

unread,
Jun 18, 2013, 4:19:25 AM6/18/13
to rubyonra...@googlegroups.com
You cannot get this value in irb.. Controller only intended to handle the request & response. Can you try that in some controller method?


Regards,
Seeni Rafiyullah Khan A,
In Every moment, thank God.


sameena Khan

unread,
Jun 18, 2013, 6:43:33 AM6/18/13
to rubyonra...@googlegroups.com

Aguardientico

unread,
Jun 18, 2013, 8:08:40 AM6/18/13
to rubyonra...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages