Search code examples
ruby-on-railswebrick

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?


Solution

  • 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