tyoshikawa1106のブログ

- Force.com Developer Blog -

Rails:rails newからrails serverコマンドの実行まで試してみました

Rails チュートリアルを読みながらrails newコマンドからrails serverコマンドの実行まで試してみました。


RailsのアプリケーションはRails newで簡単に作成できます。

$ mkdir rails_projects
$ cd rails_projects
$ rails new first_app

Gemfileの設定

アプリケーションを作成した後はGemfileの設定を行います。
※sublでSublimeを起動できるように設定しています。

$ cd first_app/
$ subl Gemfile

f:id:tyoshikawa1106:20150713235507p:plain


これでGemFileの内容を次のように変更します。


Gemfileを正しく設定した後、bundle updateとbundle installを使用してgemをインストールします。

$ bundle update
$ bundle install

f:id:tyoshikawa1106:20150714000056p:plain

rails serverの起動

以下のコマンドでローカルWebサーバーを起動できます。

$ rails server

f:id:tyoshikawa1106:20150714000235p:plain


正常に起動されると次のURLでアプリにアクセスできます。

http://localhost:3000/

f:id:tyoshikawa1106:20150714000426p:plain


rails newからrails serverの実行まではこんな感じです。起動したrails serverは『control + c』で終了できます。