1
1

More than 3 years have passed since last update.

自分用メモ(editとDelete)

Posted at

Edit

edit_post_path(post)
→postオブジェクトを渡しているので、post.idを渡している(Railsはオブジェクトを一意に表す値を取得しようとするから)
→/posts/id/というようなパスが生成

bundle install と bundle updateの違い

「前提」
(設計図)gemfile・・・gemfileに書くもの全ては書いてない
90記載

↓設計図を元に作るーbundler(gemfileに書いてないもの残り10を取ってくる)

(設計した結果)gemfile.lock
100記載

「bundle update」

gemfileを元に

bundle update

gemfile.lockを更新

「bundle install」
A,B,Cをgemとする。Bのアップデート後をB'とする。
gemfileにA,B,C
gemfile.lockにA,B'が記載されているとする

gemfile.lock

bundle install
gemfile.lockに書かれている A,B'のgemをインストール
gemfile.lockに書かれていなくて、gemfileに書かれているgem Cをインストール

gemfile.lockを更新

→gemfile.lockにもともと記載されていたgemはアップデートされない

bundle install とbundle updateの使い分け

新しい環境に変わった・新しくgemfileに新しくgemを記載した(ローカル環境で行う)

bundle install
※本番環境で行うと、gemが更新されクラッシュするので注意
ーーーー

gemのバージョン更新

bundle update

参考
https://qiita.com/lasershow/items/1a048d03ddaaba98171e

ユーザーmodel作成

メルアドはデータベースレベルで一意性を保ちたいので、indexつけて、それをunique: trueにする

bcryptとpassword_digest作ったら
models/user.rb にhas_secure_passwordを書く
→仮想属性password と password_confirmationが作られる

DB
疑問↓
データベース単位で受け取れる値を決めた方が良いのか(db:migrate前でデータの制約)
データ送信時にデータを検証した方が良いのか

1
1
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
1
1