1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use the HOST environment variable for rails server #25677

This commit is contained in:
Evgeny Vlasenko 2016-07-05 00:36:39 +06:00
parent 9552f8b457
commit e17d7275f4
2 changed files with 8 additions and 0 deletions

View file

@ -90,6 +90,7 @@ module Rails
def default_options
super.merge({
Port: ENV.fetch('PORT', 3000).to_i,
Host: ENV.fetch('HOST', 'localhost').dup,
DoNotReverseLookup: true,
environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
daemonize: false,

View file

@ -51,6 +51,13 @@ class Rails::ServerTest < ActiveSupport::TestCase
end
end
def test_environment_with_host
switch_env "HOST", "1.2.3.4" do
server = Rails::Server.new
assert_equal "1.2.3.4", server.options[:Host]
end
end
def test_caching_without_option
args = []
options = Rails::Server::Options.new.parse!(args)