Get real IP address in local Rails development environment

前端 未结 8 591
眼角桃花
眼角桃花 2020-11-30 23:15

I have Rails 2.3.8, Ruby 1.8.7, Mongrel Web Server and MySQL database.

I am in the development mode and I need to find the real IP address

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 23:25

    I had to do this:

    require 'socket'
    Socket.ip_address_list.detect(&:ipv4_private?)&.ip_address
    

提交回复
热议问题