我有以下控制人
Users :: ConfirmationsController
采取行动
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
yield resource if block_given?
if resource.errors.empty?
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ redirect_to after_confirmation_path_for(resource_name, resource) }
end
end
受保护的方法after_confirmation_path
进行重定向,
protected
def after_confirmation_path_for(resource_name, resource)
flash[:notice] = "Your account was successfully confirmed. Please sign in using the mobile application."
redirect_to "http://referd.net"
end
end
答案 0 :(得分:0)
在您的show
操作中,而不是像这样直接将after_confirmation_path_for
覆盖redirect
到其他网址。
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
flash[:notice] = "Your account was successfully confirmed. Please sign in using the mobile application."
redirect_to "http://referd.net"
else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ redirect_to after_confirmation_path_for(resource_name, resource) }
end
end
答案 1 :(得分:0)
实际上问题出在AbstractController :: DoubleRenderError,现在可以了。
class Users::ConfirmationsController < Devise::SessionsController
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
yield resource if block_given?
if resource.errors.empty?
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ redirect_to after_confirmation_path_for(resource_name, resource) }
end
end
protected
def after_confirmation_path_for(resource_name, resource)
flash[:notice] = "Your account was successfully confirmed. Please sign in using the mobile application."
**"http://referd.net"**
end
end