How to get the Client IP address with webrick

S

Sal Syed

I need to ensure that the user who has sent the request is the localhost
... what's the best way to do this?
 
S

Shai Rosenfeld

Sal said:
I need to ensure that the user who has sent the request is the localhost
... what's the best way to do this?

... i don't know how to do this via webrick, but u find out the
remote_ip that required the request in the app code simply so:
request.remote_ip

so u could do something like

class SomeController

before_filter :block_localhosts

def action1
end

def action2
end

def block_localhosts
if request.remote_ip=~/127\.0\.0\.1/
return false
end
end

end

in the example above, all requests coming from 127.0.0.1 won't be
rendered.
hth :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,006
Latest member
TerranceCo

Latest Threads

Top