あるアクション内で以下のようなコードを使用しています。
def action_name customer = ~~~ if customer.id.nil? redirect_back(fallback_location: cart_path) else redirect_to thank_you_path end end
ここで、AbstractController::DoubleRenderError
が起こったのですが、エラー文を読んだり、調べたところand return
をつけることにより明示的にアクションを終わらせれば良いとのことで、ネットで見つけた情報より以下のようなパターンを試しましたが、どれも同じエラーが出てしまい、解決できませんでした。
if customer.id.nil? redirect_back(fallback_location: cart_path) and return else redirect_to thank_you_path and return end
if customer.id.nil? redirect_back(fallback_location: cart_path) return else redirect_to thank_you_path return end
if customer.id.nil? return redirect_back(fallback_location: cart_path) else return redirect_to thank_you_path end
アクション内で他の箇所でredirect_to
及びrender
は使用していません。
またコールバックは、以下のものしか使用していません。
before_action :set_order def set_order @order = current_order end
原因のわかるかた、ご教授をお願いいたします。
あなたの回答
tips
プレビュー