0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【学習】Ruby on Rails チュートリアル 第7版 - 第1章ゼロからデプロイまで

Last updated at Posted at 2023-05-08

5/9 8:15
・クラウドIDE(AWS Cloud9)
*セットアップなどに(OSの違いなどによる)バラツキが起きづらい
*環境構築が楽

・Ruby on RailsでWeb開発を行うための準備
*Cloud9のアカウント開設
*Cloud9の初期設定
インデントはスペース2つ
*以下をインストール
Rails 7.0.4
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
Bundler version 2.3.14
・1.2まで終了
5/9 8:50

5/9 21:40
*AWS Cloud9 > Environments
openをクリックして作成したクラウドIDEを開く。

*アプリの作成
rails newで
指定のディレクトリにRailsアプリケーションのスケルトンを作成

rails 7.0.4 new hello_app --skip-bundle
※railsのバージョンを指定。bundleコマンドをスキップ
→インストールしたバージョンと互換性を保つ

*アプリに必要なgemsをインストール
bundle 2.3.14 install
※bundleのバージョンを指定。
→インストールしたバージョンと互換性を保つ

*ローカルWebサーバーを起動
rails server

*Model-View-Controller(MVC)

Railsのコントローラ(controller):Webサーバーへのリクエストを処理する
Railsのモデル(model):コントローラとの対話から、データベースとの通信を行う。
Railsのビュー(view):その名の通り。HTML コントローラがブラウザに返す。

・1.3まで終了

5/9 22:25

5/10 8:15

・git/github
※バージョン確認
git --version

 *クラウドIDEのGitをアップグレード
 source <(curl -sL https://cdn.learnenough.com/upgrade_git)
→git version 2.40.1

*パスワードの保持時間の設定※xxxxに秒数
git config --global credential.helper "cache --timeout=xxxx"

*gitの初期設定
git init
  ※rails new実行時にGitリポジトリも自動的に初期化しているが、
常にgit initを実行する癖をつけておく。

*githubにhello_appをpush

*githubの操作練習
gitでブランチ(modify-README)を作成し、
README.mdを編集。
add,commitしmainブランチにmerge
そして、githubにpushを行った。

branchの移動は↓
switch
checkoutだと思ったが、checkoutとの違いは?

⇨git switchコマンドはブランチの切り替えを専用に行うコマンドでバージョン2.23でリリース。
https://qiita.com/RINYU_DRVO/items/958e0723178f88da8101

1.4まで終了

5/10 9:16

5/10 19:50

・Renderに作成したhello_appをデプロイ
“Advanced”設定にて
環境変数RAILS_MASTER_KEYを設定する際のvalueを
config/master.keyとしていた為、失敗した。
朝にやった方が集中できる。

githubへpushすると自動でデプロイされる。
https://hello-app-9i1q.onrender.com/
1章終了!

5/10 20:30

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?