Boot up rails app, make request to app from outside local network
You can not bind the socket to your external IP. This IP is assigned to your modem (or whatever you use to connect to the internet) by your ISP. You can only bind to interfaces of your computer.
There are multiple solutions:
- Bind to 0.0.0.0:3000 (or your computers IP, not localhost) and make sure that your network forwards your public IP to your computer on that port.
- Use something like https://ngrok.com/ easy and simple
Access webrick/rails from another computer on local network
Try running the server on port 80 instead, your firewall is probably blocking port 3000.
Allow public connections to local Ruby on Rails Development Server
Give localtunnel a go. It's a ruby gem so you shouldn't have any problem getting it going:
gem install localtunnel
localtunnel 3000
The first time you do that it'll ask you for an ssh key, but once you've got that set it'll show you the public url that you can share. Anything running on the specified port will get exposed at that url.
Showoff-io looks like a similar service, but I haven't used it so I can't comment. Also, it's paid and requires signup.
Accessing rails application from another computer which is on different network
There's a gem called localtunnel. The easiest way to share localhost web servers to the rest of the world.
$ gem install localtunnel
$ localtunnel -k ~/.ssh/id_rsa.pub 3000
You should see something like this:
Port 3000 is now publicly accessible from http://8bv2.localtunnel.com ...
Hosting Rails on local network
I have been doing the same thing on a Raspberry pi with several projects.
You can actually treat your local server like an external one. You can deploy on the local server using capistrano.
Just make sure that your app on your local server will be deployed as production, not development. I would also recommend NGINX and unicorn for performance and zero downtime deployment.
Related Topics
How to Put a Raw SQL Query in Sequel
Adding to the Value in a Hash Table
How to Get Data from Database in Ruby
Making Hashes Find Each Other by Their Values Using Ruby
Transfer Db from One Heroku App to Another Faster
Devise Password Reset from Rails Console
How to Initialize an Array in One Step Using Ruby
How to Seed the Production Database Using the Capistrano Gem
Fetch VS. [] When Working with Hashes
How to Check If a Specific Key Is Present in a Hash or Not
Zsh Complains About Rvm _Rvm_Cleanse_Variables: Function Definition File Not Found
One Line If Statement Not Working
Ruby: Unexpected End-Of-Input, Expecting Keyword_End for If Statement