質問編集履歴
1
タイトル 他の選択肢のお願い等
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ジャンル別
|
1
|
+
ジャンル別 ランキング (Couldn't find all Posts with 'id':) (found 2 results, but was looking for 11)
|
test
CHANGED
@@ -1,19 +1,27 @@
|
|
1
|
-
投稿サイトを作成中で、ジャンル別に、いいね!の数のランキングを表示し
|
1
|
+
投稿サイトを作成中で、ジャンル別に、いいね!の数のランキングを表示しようとしています。
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
|
5
|
+
① 以下のエラーが出ます。どうしたらいいでしょうか? (Windows10 Ruby 2.4.4 Rails 5.1.6)
|
6
|
+
|
7
|
+
|
6
8
|
|
7
9
|
ActiveRecord::RecordNotFound in PostsController#index
|
8
10
|
|
9
|
-
Couldn't find all Posts with 'id': (#<Like:0x000000000
|
10
|
-
|
11
|
-
```
|
11
|
+
Couldn't find all Posts with 'id': (#<Like:0x000000000d1d0440>, #<Like:0x000000000d1d02d8>, #<Like:0x000000000d1d0170>, #<Like:0x000000000d1d0030>, #<Like:0x000000000d1cbeb8>, #<Like:0x000000000d1cbd78>, #<Like:0x000000000d1cbc38>, #<Like:0x000000000d1cbaa8>, #<Like:0x000000000d1cb8c8>, #<Like:0x000000000d1cb788>, #<Like:0x000000000d1cb620>) (found 2 results, but was looking for 11)
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
|
15
|
+
PostsController#index エラー箇所
|
16
16
|
|
17
|
-
|
17
|
+
@posts = Post.group(:genre_id).find(Like.group(:post_id).order('count(post_id) desc')).limit(15).pluck(:post_id).page(params[:page])
|
18
18
|
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
19
|
-
|
23
|
+
② ransackを使用して、ジャンル別ランキングを表示できますか?
|
24
|
+
|
25
|
+
(いいねの数がカラムではないため無理のようですが、ransackを使用すると表示が簡単なので、もし容易にできるようでしたら宜しくお願い致します。)
|
26
|
+
|
27
|
+
(Redis等他の方法で、初心者が使用しやすいものがあれば御提案頂ければ大変助かります。)
|