aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorAndrew White <pixeltrix@users.noreply.github.com>2017-02-27 14:49:48 +0000
committerGitHub <noreply@github.com>2017-02-27 14:49:48 +0000
commit4cc1c14493e7a9bd188ee13c237366f6bc2e13f4 (patch)
treebd35340815db8a4def83ff759d9bddf50c305625 /railties/lib
parent0bd325e5efc907ee4eade0c449c1635027ec5e6a (diff)
parent60aeb6a8f9f1fc161a921c2219650c19b6e753e7 (diff)
downloadrails-4cc1c14493e7a9bd188ee13c237366f6bc2e13f4.tar.gz
rails-4cc1c14493e7a9bd188ee13c237366f6bc2e13f4.tar.bz2
rails-4cc1c14493e7a9bd188ee13c237366f6bc2e13f4.zip
Merge pull request #28196 from y-yagi/set_correct_host_except_development_environment
Set correct host except development environment
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/commands/server/server_command.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb
index cde8b575b5..1fa27a3155 100644
--- a/railties/lib/rails/commands/server/server_command.rb
+++ b/railties/lib/rails/commands/server/server_command.rb
@@ -99,8 +99,9 @@ module Rails
class_option :port, aliases: "-p", type: :numeric,
desc: "Runs Rails on the specified port.", banner: :port, default: 3000
- class_option :binding, aliases: "-b", type: :string, default: "localhost",
- desc: "Binds Rails to the specified IP.", banner: :IP
+ class_option :binding, aliases: "-b", type: :string,
+ desc: "Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'.",
+ banner: :IP
class_option :config, aliases: "-c", type: :string, default: "config.ru",
desc: "Uses a custom rackup configuration.", banner: :file
class_option :daemon, aliases: "-d", type: :boolean, default: false,
@@ -187,7 +188,10 @@ module Rails
end
def host
- ENV.fetch("HOST", options[:binding])
+ unless (default_host = options[:binding])
+ default_host = environment == "development" ? "localhost" : "0.0.0.0"
+ end
+ ENV.fetch("HOST", default_host)
end
def environment