Railsの一般的なユーザー - 投稿モデルでは、すべてのユーザーが投稿を作成してコメントを作成することができ、質問は特定の投稿のすべてのユーザーの最新コメントを取得する方法です。それを行うにはどのようにRailsの最新のコメントのみを取得
Post A have 3 user making comment
User 1 latest comment that is 6
User 2 latest comment that is 4
user 3 latest comment that is 2
:
Example:
Post A have 3 user making comment
User 1 have comment 1, 2, 3, 4, 5, 6
User 2 have comment 1, 2, 3, 4
User 3 have comment 1, 2
だから私はしたいビューは、すべてのユーザーのためのちょうど最新コメントのですか?
おかげで、このような
そのPostモデルのhas_manyのユーザー、またはそれhas_manyのコメントはそのこれは、ユーザーに帰属しますか? – Matchu
ユーザーには多くの投稿とコメントがあり、投稿は多くのコメントを持ち、ユーザーに属しています。コメントは投稿に属し、ユーザーに属します。 – gkrdvl