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 3 years have passed since last update.

findのまとめ find_byのまとめ whereのまとめ

Posted at

findのまとめ
・主キーに対応するレコードを取り出す
・主キーを複数指定することも可能
・主キーが1つでも見つからない場合ActiveRecord::RecordNotFound例外が発生する
・findで取得したオブジェクトのクラスはBook 

find_byのまとめ
・与えられた条件にマッチするレコードのうち最初のレコードだけを返す
・条件を複数指定することができる
・与えられた条件がない場合nilを返す
・find_byで取得したオブジェクトのクラスはBook

whereのまとめ
・与えられた条件にマッチするレコードをすべて返す。
・NOT条件
・AND条件
・OR条件
・条件にマッチしない場合は空の配列を返す
・取得したオブジェクトのクラスはBook::ActiveRecord_Relation

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?