railsを使っていて、開発環境ではうまく動いたのですが
本番環境では下記のエラーが表示させてしまいます。
ログを見てみたのですが問題点が分からず投稿いたしました。
エラー箇所と、もし可能であれば修正方法をご教授いただけましたら幸いです。
以下 heroku logsの内容になります。
rails
12020-08-11T04:17:26.573250+00:00 app[web.1]: I, [2020-08-11T04:17:26.573127 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Started GET "/" for 27.141.86.191 at 2020-08-11 04:17:26 +0000 22020-08-11T04:17:26.580117+00:00 app[web.1]: I, [2020-08-11T04:17:26.580014 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Processing by StaticPagesController#home as HTML 32020-08-11T04:17:26.582201+00:00 app[web.1]: I, [2020-08-11T04:17:26.582119 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Rendering static_pages/home.html.erb within layouts/application 42020-08-11T04:17:26.584178+00:00 app[web.1]: I, [2020-08-11T04:17:26.584098 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Rendered shared/_header.html.erb (0.5ms) 52020-08-11T04:17:26.584997+00:00 app[web.1]: I, [2020-08-11T04:17:26.584905 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Rendered shared/_search.html.erb (0.5ms) 62020-08-11T04:17:26.589138+00:00 app[web.1]: D, [2020-08-11T04:17:26.589055 #4] DEBUG -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Dog Load (1.2ms) SELECT "dogs".* FROM "dogs" 72020-08-11T04:17:26.590601+00:00 app[web.1]: I, [2020-08-11T04:17:26.590523 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Rendered shared/_kind_dogs.html.erb (5.3ms) 82020-08-11T04:17:26.594295+00:00 app[web.1]: I, [2020-08-11T04:17:26.594214 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Rendered shared/_side_bar_col3.html.erb (0.3ms) 92020-08-11T04:17:26.605317+00:00 app[web.1]: D, [2020-08-11T04:17:26.605154 #4] DEBUG -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] SQL (2.3ms) SELECT "foods"."id" AS t0_r0, "foods"."name" AS t0_r1, "foods"."created_at" AS t0_r2, "foods"."updated_at" AS t0_r3, "foods"."image" AS t0_r4, "foods"."detaile" AS t0_r5, "foods"."price" AS t0_r6, "foods"."japan" AS t0_r7, "foods"."try" AS t0_r8, "foods"."grain" AS t0_r9, "microposts"."id" AS t1_r0, "microposts"."content" AS t1_r1, "microposts"."user_id" AS t1_r2, "microposts"."created_at" AS t1_r3, "microposts"."updated_at" AS t1_r4, "microposts"."rate" AS t1_r5, "microposts"."dog_id" AS t1_r6, "microposts"."food_id" AS t1_r7, "microposts"."likes_count" AS t1_r8, "microposts"."title" AS t1_r9 FROM "foods" LEFT OUTER JOIN "microposts" ON "microposts"."food_id" = "foods"."id" GROUP BY food_id ORDER BY avg(microposts.rate) desc 102020-08-11T04:17:26.611224+00:00 app[web.1]: I, [2020-08-11T04:17:26.610733 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Rendered shared/_ranking.html.erb (16.1ms) 112020-08-11T04:17:26.611498+00:00 app[web.1]: I, [2020-08-11T04:17:26.611400 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Rendered static_pages/home.html.erb within layouts/application (29.1ms) 122020-08-11T04:17:26.612881+00:00 app[web.1]: I, [2020-08-11T04:17:26.612765 #4] INFO -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] Completed 500 Internal Server Error in 32ms (ActiveRecord: 3.5ms) 132020-08-11T04:17:26.621717+00:00 app[web.1]: F, [2020-08-11T04:17:26.619380 #4] FATAL -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] 142020-08-11T04:17:26.621861+00:00 app[web.1]: F, [2020-08-11T04:17:26.621772 #4] FATAL -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] ActionView::Template::Error (PG::GroupingError: ERROR: column "foods.id" must appear in the GROUP BY clause or be used in an aggregate function 152020-08-11T04:17:26.621863+00:00 app[web.1]: LINE 1: SELECT "foods"."id" AS t0_r0, "foods"."name" AS t0_r1, "food... 162020-08-11T04:17:26.621863+00:00 app[web.1]: ^ 172020-08-11T04:17:26.621872+00:00 app[web.1]: : SELECT "foods"."id" AS t0_r0, "foods"."name" AS t0_r1, "foods"."created_at" AS t0_r2, "foods"."updated_at" AS t0_r3, "foods"."image" AS t0_r4, "foods"."detaile" AS t0_r5, "foods"."price" AS t0_r6, "foods"."japan" AS t0_r7, "foods"."try" AS t0_r8, "foods"."grain" AS t0_r9, "microposts"."id" AS t1_r0, "microposts"."content" AS t1_r1, "microposts"."user_id" AS t1_r2, "microposts"."created_at" AS t1_r3, "microposts"."updated_at" AS t1_r4, "microposts"."rate" AS t1_r5, "microposts"."dog_id" AS t1_r6, "microposts"."food_id" AS t1_r7, "microposts"."likes_count" AS t1_r8, "microposts"."title" AS t1_r9 FROM "foods" LEFT OUTER JOIN "microposts" ON "microposts"."food_id" = "foods"."id" GROUP BY food_id ORDER BY avg(microposts.rate) desc): 182020-08-11T04:17:26.622245+00:00 app[web.1]: F, [2020-08-11T04:17:26.622166 #4] FATAL -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] 7: <div class="ranking-kind"> 192020-08-11T04:17:26.622246+00:00 app[web.1]: [d2b3adea-90e5-4003-822a-fbc49c224a0e] 8: <ol class="d-flex justify-content-between"> 202020-08-11T04:17:26.622247+00:00 app[web.1]: [d2b3adea-90e5-4003-822a-fbc49c224a0e] 9: 212020-08-11T04:17:26.622248+00:00 app[web.1]: [d2b3adea-90e5-4003-822a-fbc49c224a0e] 10: <% @foods.order("avg(microposts.rate) desc").each_with_index do |food,n| %> 222020-08-11T04:17:26.622248+00:00 app[web.1]: [d2b3adea-90e5-4003-822a-fbc49c224a0e] 11: <% break if n==3 %> 232020-08-11T04:17:26.622249+00:00 app[web.1]: [d2b3adea-90e5-4003-822a-fbc49c224a0e] 12: <li class="rank-category"> 242020-08-11T04:17:26.622250+00:00 app[web.1]: [d2b3adea-90e5-4003-822a-fbc49c224a0e] 13: <!-- 商品画像--> 252020-08-11T04:17:26.624168+00:00 app[web.1]: F, [2020-08-11T04:17:26.622295 #4] FATAL -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] 262020-08-11T04:17:26.624310+00:00 app[web.1]: F, [2020-08-11T04:17:26.624236 #4] FATAL -- : [d2b3adea-90e5-4003-822a-fbc49c224a0e] app/views/shared/_ranking.html.erb:10:in `each_with_index' 272020-08-11T04:17:26.624311+00:00 app[web.1]: [d2b3adea-90e5-4003-822a-fbc49c224a0e] app/views/shared/_ranking.html.erb:10:in `_app_views_shared__ranking_html_erb__1684178908291161544_47314502689060' 282020-08-11T04:17:26.624312+00:00 app[web.1]: [d2b3adea-90e5-4003-822a-fbc49c224a0e] app/views/static_pages/home.html.erb:40:in `_app_views_static_pages_home_html_erb___3541224926667824017_47314502341340' 292020-08-11T04:17:26.625163+00:00 heroku[router]: at=info method=GET path="/" host=warm-harbor-81729.herokuapp.com request_id=d2b3adea-90e5-4003-822a-fbc49c224a0e fwd="27.141.86.191" dyno=web.1 connect=1ms service=55ms status=500 bytes=1891 protocol=https
回答2件
あなたの回答
tips
プレビュー