Info

Portが3000のやつがたくさん出てきたので、Railsのデフォルトポートを変えてみる。

1. script/rails

APP_PATH = File.expand_path('../../config/application',  __FILE__)
require File.expand_path('../../config/boot',  __FILE__)

# THIS IS NEW:
require "rails/commands/server"
module Rails
  class Server
    def default_options
      super.merge({
        :Port        => 3001,
        :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 OF CHANGE
require 'rails/commands'

メリット:プロジェクトごとに変更可能。
デメリット:gitなどの共有される時にpushすると他人に影響を及ぼす

2. server.rb 編集

$ pwd
/Users/dongri/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.13/lib/rails/commands
$ vim server.rb
    def default_options
      super.merge({
        :Port        => 3001,
        :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
$

メリット:自分だけの環境なので、gitなどで共有されず、他人に影響なし
デメリット:プロジェクト共通になる。

Comments

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS