I\'d like to bind the rails server to 127.0.0.1, instead of 0.0.0.0 so its not accessible when I\'m working from coffee shops.
Is there a configuration file where I can
If you put the default options on config/boot.rb
then all command attributes for rake and rails fails (example: rake -T
or rails g model user
)! So, append this to bin/rails
after line require_relative '../config/boot'
and the code is executed only for the rails server command:
if ARGV.first == 's' || ARGV.first == 'server'
require 'rails/commands/server'
module Rails
class Server
def default_options
super.merge(Host: '127.0.0.1', Port: 10524)
end
end
end
end
The bin/rails
file loks like this:
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
# Set default host and port to rails server
if ARGV.first == 's' || ARGV.first == 'server'
require 'rails/commands/server'
module Rails
class Server
def default_options
super.merge(Host: '127.0.0.1', Port: 10524)
end
end
end
end
require 'rails/commands'