ドットインストールより

①Railsインストール
gem install rails –no-document

②プロジェクト初期化
rails new [myapp]

③動作確認(webサーバ起動)
rails server -b [xxx.xxx.xxx.xxx] -d

④webサーバ停止(プロセスkill)
(1)cat tmp/pids/server.pid
(2)ps aux | grep puma
⇒ pidが表示される
#kill -9 [pid]

※ログ格納箇所
tail log/development.log

⑤Scaffoldでメモアプリ作成
rails g(enerate) scaffold Memo title:string body:text
rails db:migrate

⑥model作成(MVCのM)
rails g model Post title:string body:text
rails db:migrate
※コンソールから入力
rails c
p = Post.new(title: ‘title 1’, body: ‘body 1’)
p. save
Post.create(title: ‘title 2’, body: ‘body 2’)
Post.all
quit

⑦db確認
rails db(console)
=> sqlite起動
.tables
.quit

※DB内容をクリア
rails db:migrate:reset

rails db:seed

Follow me!