Hit the books!!

プログラミング学習記録

Ruby on Railsのインストール

今日からウワサのRuby on Railsの学習に入りました!

フィヨルドブートキャンプのカリキュラムの進捗率は57%、総学習時間は626.8時間。

矢印のところが現在地です。

f:id:ud_ike:20200920221203p:plain

Railsのインストールが思った以上に手こずったのでメモ。(思った以上に~のくだり、毎回書いてる気がしないでもない)

環境:macOS Catalina / Ruby 2.7.1

参考サイト

Railsをインストール

gemのインストールも手慣れたもんよ。

% gem install rails
% bundle install

bundleを使ったgemの管理についてはこちら↓

ud-ike.hatenablog.com

rails newを実行

web_appsというディレクトリを作成し移動。rails newコマンドを実行する。

% cd web_apps
% bundle exec rails new helloworld

エラーが出た。

cannot load such file -- bootsnap/setup

調べたところ、Gemfileに以下を追記したら解消された。

gem 'bootsnap', require: false

web_apps配下にできたhelloworldディレクトリを削除してから再びrails new helloworldを実行し直した。

で、調べたらNode.jsとYarnっていうのも必要らしいじゃないの。これもHomebrewでインストールした。

rails serverを実行

さっきのrails new helloworldコマンドで作成されたhelloworldへ移動してrails serverを実行。

% cd helloworld 
% bundle exec rails server

rails sとserverを省略してもOK。

またエラーが出たよ。

 Please run rails webpacker:install Error: No such file or directory ~

書いてある通り実行した。

% bundle exec rails webpacker:install

再びrails serverコマンドを実行したらできた〜。

ブラウザでhttp://localhost:3000にアクセスすると楽しそうな画像が!

f:id:ud_ike:20200920224037p:plain

Railsのバージョンは6.0だって。

 % rails --version
Rails 6.0.3.3

まだ何もわかってないけど、これからどんどん勉強するぞーー