After upgrading our team's rails application to 4.2, as the release note mentioned, the default ip rails server
binds to is changed to localhost
from 0.0.0.0
.
We develop with Vagrant, and want the development server to be accessible directly from browser on the host machine.
Instead of typing rails s -b 0.0.0.0
every time from now on, I wonder if there's any more elegant solution, so that we can still use sth as simple as rails s
to start the server. Perhaps:
- a config file
rails s
reads where I can modify the default binding ip (without using -c
)
- port forward with vagrant (tried but failed, see problem encountered below)
- a monkey patch to rack, that changes the default binding ip
The real goal behind this is that I want the upgrade to be smooth among our team, avoiding the glitch that people will have to constantly restarting their rails server due to the missing -b 0.0.0.0
part.
I tried vagrant port forwarding, but still get Connection Refused
when I visit localhost:3000
on the host machine. The two configuration lines I tried was:
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 3000, guest_ip: '127.0.0.1', host: 3000
Didn't find any relevant instructions in the official docs. Any help will be appreciated.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…