Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hxx/5c1641d314403d12dd34 to your computer and use it in GitHub Desktop.
Save hxx/5c1641d314403d12dd34 to your computer and use it in GitHub Desktop.
Genymotion localhost IP and rails service

使用 Genymotion 作为 Android Emulator 时,本地调用 Rails 作为 API 后台的 IP 地址,

应该使用 10.0.3.2 来代替 localhost

同时,Rails 服务启动的时候需要使用

rails s -b 0.0.0.0

使用 Android Emulator 相当于是局域网里的另一台机器来访问 Rails 服务,而在 Rails 4.2 以后修改了 Rails Server 默认的的 Host, 所以要使用上面的命令来让 Android Emulator 可以访问 Rails Service,同时需要注意使用防火墙策略来只让受信任的机器访问你的开发服务器。

参考:http://guides.rubyonrails.org/4_2_release_notes.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment