简体   繁体   中英

Ruby - Get client IP Address from inside a gem

I'm trying to create a gem and I would like to have a feature inside it that takes the client ip address when using it. Basically it's just like the rails ActionController request.remote_ip , but within the gem I don't want to rely/depend on rails.

Is there any way to have something like this purely using Ruby?

I've found this , but when deployed to a production server it only gets the server ip address and not the client one.

Any help would be pretty much appreciated

Thanks a lot

it's possible because of Ruby :) if you are developing a web app you should use rack ! it's pretty cool and simple otherwise you will have to deal with the 'net' module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM