how do i run a development rails app / website on an ipod

后端 未结 5 1316
北海茫月
北海茫月 2021-01-04 08:19

I have a app / site that i am running on my local imac and i want to test it on my ipad browser.

Can connect to my imac localhost rails app throught the wifi wit

相关标签:
5条回答
  • 2021-01-04 09:00

    I'm providing an update for anyone who's using Rails 4, has followed the steps in the accepted answer, and still can't connect to the app via development_machine_ip:3000. The reason being that somewhere around version 4, Rails changed the default binding address from 0.0.0.0 to only localhost. By default this allows you to only access the Rails app via localhost:3000 or 127.0.0.1:3000 - which is fine in most cases.

    Now if you'd like to access the app from a different device on your network, you can use the -b option when starting the server and specify a binding address of 0.0.0.0

    rails s -b 0.0.0.0
    

    This will bind on ALL interfaces including localhost and the IP assigned by your network. You should now be able to access the app via development_machine_ip:3000.

    0 讨论(0)
  • 2021-01-04 09:00

    I use proxylocal ngrok for this:

    $ ngrok http 3000
    ngrok by @inconshreveable                                                                                                                       (Ctrl+C to quit)
    
    Session Status                online
    Account                       Sergio (Plan: Free)
    Version                       2.2.8
    Region                        United States (us)
    Web Interface                 http://127.0.0.1:4040
    Forwarding                    http://be278635.ngrok.io -> localhost:3000
    Forwarding                    https://be278635.ngrok.io -> localhost:3000
    
    Connections                   ttl     opn     rt1     rt5     p50     p90
                                  0       0       0.00    0.00    0.00    0.00
    

    Now you can open http://be278635.ngrok.io from your ipad without worrying about your machine's ip address.

    0 讨论(0)
  • 2021-01-04 09:01

    If the subdomain is just going to 127.0.0.1:3000 (or whatever) you should be able to access it the same way by going to your machine's local IP address with the same supplied port number. I look at my rails app on my phone all the time.

    If you have virtual hosts or something set up, it's probably going to be more complicated than that.

    0 讨论(0)
  • 2021-01-04 09:10

    For this, you would either need to jailbreak your iPad to edit the /etc/hosts file, or add a DNS entry in your router (assuming your router is your DNS server).

    One of those two sounds like the easiest.

    0 讨论(0)
  • 2021-01-04 09:14

    I am hoping that your macbook and iPad are on same network. Now go to "Open network preference". Check screenshot.

    You will see an ip.

    enter image description here

    then from ipad open: your_ip:3000

    0 讨论(0)
提交回复
热议问题