Rails 4 How Overwrite Devise Respond Path Upon Error

后端 未结 3 2105
说谎
说谎 2021-02-13 09:38

I\'ve been struggling for a while with this one. I have a Rails4/Devise 3.1 app with two users in the system:

  1. Graduates
  2. Employers

and o

3条回答
  •  野性不改
    2021-02-13 10:27

    Calling respond_with will render the default action of that resource. This I believe is the index action (/users/) and thus the cause for the redirect.

    I think what you want to do is render the new action instead. Try the following:

    if resource.save
      ...
    else
      clean_up_passwords(resource)
      render :action => 'new'
    end
    

提交回复
热议问题