简体   繁体   中英

How to set default port for Webrick?

I want to set the default port when I do

rails s

to 3010, instead of having to say:

rails s -p 3010

...every time. Any ideas?

You can override the Port by adding the following code to config/boot.rb

require 'rails/commands/server'
module Rails
  class Server
    alias :default_options_alias :default_options
    def default_options
      default_options_alias.merge!(:Port => 3010)
    end    
  end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM