Railsでアプリケーションをローカルで起動する際に
ターミナルでrails s実行し
ブラウザでlocalhost:3000を入力すると表示されると思います。
これって何をしてるのと疑問に思ったので書いてみました。
##rails sについて
まず、railsのアプリを起動する為にはアプリケーションサーバを起動する必要があります。
それを担っているのが、rails sです。
rails sを実行するとpumaと呼ばれるアプリケーションサーバが起動します。
下の =>Booting Pumaです。
$rails s
=> Booting Puma
=> Rails 5.0.7.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.3.1-p112), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
つまりrails sでアプリケーションサーバを起動しています。
##localhost:3000について
localhost:3000とは自身のPCを指すドメインの事です。
つまり自身のPCをアプリケーションサーバにみたてて(rails sで)ブラウザでlocalhost:3000というドメインにアクセスさせる事で自身の書いたアプリケーションが表示されているという事です!