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.

Micropost.where("user_id IN (?) OR user_id = ?", following_ids, id)は何している?

Posted at
Micropost.where("user_id IN (?) OR user_id = ?", following_ids, id)

上記の内容が理解があいまいで、まとめる。
user_id IN (?)がfollowing_ids に対応。user_id = ?がid に対応?
一応私の認識としては以下を考えてます。

micropostのカラムからwhereのものを取得。
以下where内
user_id IN (?)はfollowing_idsの中にあるuser_idをとってくる。
例えば、following_ids =[“2”,“3",“4”,“5"]だった場合、user_id IN(?) でmicropostのカラムからuser_id=2, 3, 4, 5のみを取得。
user_id = ?は現在ログイン中のid(インスタンス変数かセッションから取得?)のuser_idを取得
例えば現在ログイン中のidが1の場合user_id=?の?に1が入るイメージ

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?