質問編集履歴
6
情報の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
ローカル環境や本番環境では問題ないのですが、staging環境でのみDoubleRenderErrorが出ます。
|
2
2
|
エラーメッセージの最後にredirect_to(...) and returnとあるのですが、このアクション内にはredirect_toもrenderもないため、別のところに問題があると推測しています。
|
3
|
-
|
3
|
+
サーバーが立ち上がらなくなったことがあり、それを復旧した際の処理の何かがおそらく引っかかっているのだと思います。
|
4
4
|
|
5
5
|
## エラー全文
|
6
6
|
AbstractController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".):
|
5
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -98,6 +98,16 @@
|
|
98
98
|
end
|
99
99
|
```
|
100
100
|
|
101
|
+
また、application_controller.rbのhandle_505内の
|
102
|
+
```ruby
|
103
|
+
return render template: 'errors/error_500', status: 500, layout: false, content_type:
|
104
|
+
```
|
105
|
+
の一行を
|
106
|
+
```ruby
|
107
|
+
render template: 'errors/error_500', status: 500, layout: false, content_type: and return
|
108
|
+
```
|
109
|
+
と変えてみましたがエラーメッセージに変化はありませんでした。
|
110
|
+
|
101
111
|
## 実現したいこと
|
102
112
|
|
103
113
|
staging環境でのみAbstractController::DoubleRenderErrorが起こる原因を究明したいです。
|
4
情報修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,7 +39,7 @@
|
|
39
39
|
end
|
40
40
|
```
|
41
41
|
staging.logでログを確認すると、
|
42
|
-
logger.debug("ggggggggggggggggggggggggggggggggg")までは問題ないようですが、logger.debug("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")がなく、DownloadLog.create(user_id: current_user.id, product_id: @product.id)の部分でエラーが起きているようです。
|
42
|
+
logger.debug("ggggggggggggggggggggggggggggggggg")までは問題ないようですが、logger.debug("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")でのデバッグがなく、DownloadLog.create(user_id: current_user.id, product_id: @product.id)の部分でエラーが起きているようです。
|
43
43
|
|
44
44
|
|
45
45
|
```
|
3
情報修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -100,5 +100,5 @@
|
|
100
100
|
|
101
101
|
## 実現したいこと
|
102
102
|
|
103
|
-
staging環境のみ
|
103
|
+
staging環境でのみAbstractController::DoubleRenderErrorが起こる原因を究明したいです。
|
104
104
|
ご教示いただけることがあれば、何卒よろしくお願いいたします。
|
2
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
app/controllers/application_controller.rb:51:in `block (2 levels) in handle_500'
|
57
57
|
app/controllers/application_controller.rb:49:in `handle_500'
|
58
58
|
```
|
59
|
-
Rendering 500 with exception: undefined method `[]' for nil:NilClassとありますが、[]を記述していないので、なぜこのエラーができているのかわかりません。model/download_log.rbにも記述はありませんでした。
|
59
|
+
Rendering 500 with exception: undefined method `[]' for nil:NilClassとありますが、[]を記述していないので、なぜこのエラーができているのかわかりません。model/download_log.rbにもapplication_controller.rbのhandle500にも記述はありませんでした。
|
60
60
|
|
61
61
|
```ruby
|
62
62
|
# model/download_log.rb
|
@@ -76,6 +76,28 @@
|
|
76
76
|
|
77
77
|
```
|
78
78
|
|
79
|
+
```ruby
|
80
|
+
# application_controller.rb
|
81
|
+
|
82
|
+
class ApplicationController < ActionController::Base
|
83
|
+
protect_from_forgery with: :exception
|
84
|
+
rescue_from Exception, with: :handle_500 unless Rails.env.development?
|
85
|
+
|
86
|
+
def handle_500(exception = nil)
|
87
|
+
logger.error "Rendering 500 with exception: #{exception.message}" if exception
|
88
|
+
ExceptionNotifier.notify_exception(exception, env: request.env, data: {message: "error"})
|
89
|
+
respond_to do |format|
|
90
|
+
format.html {
|
91
|
+
return render template: 'errors/error_500', status: 500, layout: false, content_type: 'text/html'
|
92
|
+
}
|
93
|
+
format.all {
|
94
|
+
return head :internal_server_error
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
79
101
|
## 実現したいこと
|
80
102
|
|
81
103
|
staging環境のみで問題が起こる原因を究明したいです。
|
1
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,6 +5,11 @@
|
|
5
5
|
## エラー全文
|
6
6
|
AbstractController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".):
|
7
7
|
|
8
|
+
## 環境
|
9
|
+
macOS High Sierra(バージョン10.13.6)
|
10
|
+
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin17]
|
11
|
+
Rails 4.2.6
|
12
|
+
|
8
13
|
##試したこと
|
9
14
|
以下のようにproduct_controllerのdownloadzipアクションにデバッグを追加してログを確認してみました。
|
10
15
|
|