How to change default port of a Rails 4 app?

前端 未结 5 541
礼貌的吻别
礼貌的吻别 2020-12-08 03:23

I know that I can start a rails server on another port via -p option. But I\'d like to setup another port per application as long as I start webrick.

An

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 03:28

    For Rails 5.1:

    # config/boot.rb
    
    # ... existing code
    
    require 'rails/command'
    require 'rails/commands/server/server_command'
    
    Rails::Command::ServerCommand.send(:remove_const, 'DEFAULT_PORT')
    Rails::Command::ServerCommand.const_set('DEFAULT_PORT', 3333)
    

提交回复
热议问题