1

I'm using ruby with Sinatra. I want get the public ip of visitors and save it in a database, but a don't know how get the ip... Sorry, but I have not found a way to do that. Guys can help me? Thank you!

  • This didn't work..??. `ip_addr = request.env['REMOTE_ADDR']` – Hiren Pandya Apr 11 '13 at 04:48
  • This might also help... http://stackoverflow.com/questions/4465476/rails-get-client-ip-address – Hiren Pandya Apr 11 '13 at 04:49
  • And this... http://stackoverflow.com/questions/1226959/how-to-get-client-ip-and-server-ip-using-rails .. Please try to google something before just giving up on it.. and show some efforts and show us then and only then we can help... Thank you.. – Hiren Pandya Apr 11 '13 at 04:50
  • 3
    Except all those examples are for rails, so please try reading the question before posting snide comments. – sevenseacat Apr 11 '13 at 05:05

1 Answers1

8

According to the Sinatra documentation, you can use

request.ip
ian
  • 12,003
  • 9
  • 51
  • 107
Jun Zhou
  • 3,060
  • 1
  • 20
  • 31