12
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails | Devise: DoubleRenderError

Last updated at Posted at 2019-08-28

Deviseをいじいじしたあと、サインアップを試みるとこんなエラーが...

AbstractController::DoubleRenderError in Users::SessionsController#create
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".

解決方法

Devise: コントローラのオーバライドでredirect_toを使わない

  • 原因となった箇所

def after_sign_up_path_for
  redirect_to users_path
end
  • 修正
def after_sign_up_path_for
  users_path
end

理由

redirect_to users_path

# deviseの仕様上、上記の記述は以下と同義となってしまうから

redirect_to(redirect_to(users_path))

助けられた記事

Rails, Devise: DoubleRenderError in FailureApp

12
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?