LoginSignup
1
0

More than 3 years have passed since last update.

CRUD処理について

Posted at

CRUD処理とは

CRUDはcreate、read、update、deleteの頭文字をとった造語で、データベースの処理を表す言葉

処理一覧

Create処理(データの追加)


User.create(name:A,age:21)

Read処理(データの読み込み)


User.all                   # データを全て取得
User.find(2)         # 指定したidを取得
User.find_by(name:A)   # 最初にヒットしたデータを取得
User.where(age:29)      # 該当のデータ全て取得

Update処理(データの更新)


user=User.find(1)

User.age=22

user.save

Delete処理(データの削除)


user=User.find(1)

user.destroy
1
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
1
0