Aut*_*act 11 mobile-phones ruby-on-rails wifi
我的rails网站是我在localhost Ubuntu上开发的,我有一个移动设备.我的网站运行在http:// localhost:3000
现在我想直接通过我的移动浏览器访问它而不通过互联网.
有没有办法通过wifi或其他方式访问它?
mar*_*cgg 24
如果您的计算机可从互联网访问,只需输入:
http://your.ip:3000/
Run Code Online (Sandbox Code Playgroud)
在您的移动浏览器中.
你也可以创建一个本地网络(例如通过wifi),用你的手机连接到它,然后做同样的事情.
如果您使用的是Rails 4.2,__CODE__请使用启动服务器(请参阅http://edgeguides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server).
使用ngrok
所以基本上,你运行命令
./ngrok http 3000
Run Code Online (Sandbox Code Playgroud)
你会看到这样的输出 
您只需复制突出显示的网址并粘贴到浏览器即可.
1.)输入以下命令获取本地IP:
ifconfig |grep inet
进入您的外壳/终端。您的IP通常看起来像这样:192.xxx.xxx.xx
2.)然后使用以下命令启动Rails服务器:
rails server -b 0.0.0.0
3.)现在可以通过键入以下内容访问您的应用程序:
192.xxx.xxx.xx:3000 进入浏览器。