ruby-on-railscurlopen-uri

Setting outgoing IP address in open-uri with RoR


I'm new to open-uri and trying to set an outgoing IP address using open-uri in ruby on rails. I used this post as a reference to get started. I'm porting an app from PHP where I could use CURLOPT_INTERFACE in curl_setopt. What's the best way to do this using open-uri in rails? (Doing this from the controller - not command line.)

If there's not a way to do this - any suggestions on an alternative to open-uri? My goal is to take in and parse JSON data.


Solution

  • What I understand from your questions is you want to hit another server from a specific IP which suggests you have a server with couple of addresses.

    What I can suggest you is try to execute curl directly and do what you want to do or use a wrapper for it.