Ruby on rails 尽管使用了if-then语句,但Rails双渲染错误

Ruby on rails 尽管使用了if-then语句,但Rails双渲染错误,ruby-on-rails,ruby-on-rails-4,redirect,devise,Ruby On Rails,Ruby On Rails 4,Redirect,Devise,我经常使用render和redirect_to,但在if…then语句中组合使用,这样默认情况下操作只有1个。我不知道为什么Desive在这种情况下不起作用 我需要做的是,无论用户是否被确认,在他/她成功注册后,我需要立即发布到另一个控制器以创建其他内容,这就是为什么重定向到是相同的。但是我得到了DoubleRender错误 谢谢 以下是设计代码,供您参考: # POST /resource def create build_resource(sign_up_params) resou

我经常使用
render
redirect_to
,但在
if…then
语句中组合使用,这样默认情况下操作只有1个。我不知道为什么Desive在这种情况下不起作用

我需要做的是,无论用户是否被确认,在他/她成功注册后,我需要立即发布到另一个控制器以创建其他内容,这就是为什么重定向到是相同的。但是我得到了
DoubleRender
错误

谢谢

以下是设计代码,供您参考:

# POST /resource
def create
  build_resource(sign_up_params)

  resource.save
  yield resource if block_given?
  if resource.persisted?
    if resource.active_for_authentication?
      set_flash_message :notice, :signed_up if is_flashing_format?
      sign_up(resource_name, resource)
      respond_with resource, location: after_sign_up_path_for(resource)
    else
      set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
      expire_data_after_sign_in!
      respond_with resource, location: after_inactive_sign_up_path_for(resource)
    end
  else
    clean_up_passwords resource
    set_minimum_password_length
    respond_with resource
  end
end
然后我的代码:

def after_sign_up_path_for(resource)
  redirect_to "/plan_date_create"
end

def after_inactive_sign_up_path_for(resource)
  redirect_to "/plan_date_create"
end

respond\u with
s进行渲染,然后
after\u-sign\u-path\u for
after\u-inactive\u-sign\u-path\u for
执行重定向,您将调用
respond\u with
和同一行代码中的一个或另一个方法