Вы можете обновить файл / script / rails в вашем приложении rails, чтобы отобразить следующее:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
# START NEW CODE
require "rails/commands/server"
module Rails
class Server
def default_options
super.merge({
:Host => 'my-host.com',
:Port => 3000,
:environment => (ENV['RAILS_ENV'] || "development").dup,
:daemonize => false,
:debugger => false,
:pid => File.expand_path("tmp/pids/server.pid"),
:config => File.expand_path("config.ru")
})
end
end
end
# END NEW CODE
require 'rails/commands'
Это будет привязывать приложение rails к my-host.com при запуске.Вы все еще можете переопределить параметры из командной строки.
Я не уверен, почему это не отражено в документации по Rails :: Server API.Вы можете взглянуть на https://github.com/rails/rails/blob/master/railties/lib/rails/commands/server.rb, чтобы увидеть реализацию сервера.
Обратите внимание, что в Rails 4 файл / script / rails был перемещен в /bin/rails.