Last active
August 29, 2015 14:22
-
-
Save lime/611e4ad2f997c52c0b84 to your computer and use it in GitHub Desktop.
Change default_options for Rails::Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Override default options for server command | |
# This example changes default development host to 127.0.0.1 | |
require 'rails/commands/server' | |
module Rails | |
class Server | |
new_defaults = Module.new do | |
def default_options | |
environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' | |
default_host = environment == 'development' ? '127.0.0.1' : '0.0.0.0' | |
super.merge( Host: default_host ) | |
end | |
end | |
# Note: Module#prepend requires Ruby 2.0 or later | |
prepend new_defaults | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment