ruby-on-rails - 更改设备注册路径

标签 ruby-on-rails redirect devise sign

我需要将用户重定向到除根页面之外的单独页面

这是我的注册 Controller (覆盖 after_sign_up_path_for 方法):

class RegistrationsController < Devise::RegistrationsController
  
  protected
    def after_sign_up_path_for(resource)
      redirect_to xxxx_path
    end
end

我收到以下错误:

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".)

最佳答案

您的问题在于重定向,在方法中只需编写 foo_path 而不是 redirect_to foo_path

您的代码应如下所示 registrations_controller.rb

class RegistrationsController < Devise::RegistrationsController
  def after_sign_up_path_for(resource)
    foo_path
  end
end

这应该可以解决您的问题。

关于ruby-on-rails - 更改设备注册路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26763805/

相关文章:

ruby-on-rails - 脚手架测试失败,ActionController::InvalidAuthenticityToken

ruby-on-rails - 性能问题 : use "link_to" or "a"?

ruby-on-rails - 自动为用户设置密码 - Devise

javascript - rails : How to confirm email address entered in text box matches current user's email address?

ruby-on-rails - Devise 在生产环境中不发送邮件

ruby-on-rails - Rails 和 respond_with : why are the status codes not right?

ruby-on-rails - Ruby、HTTParty、SSL 错误

c# - 拦截来自 UpdatePanel 帖子的重定向

redirect - 捕获 302 错误,然后在backbone.js 同步方法重写中重定向

java - 在 java 中读取 URL 的内容 - 重定向问题