尽管使用if then语句

时间:2015-05-24 22:44:05

标签: ruby-on-rails ruby-on-rails-4 redirect devise

我经常同时使用renderredirect_to,但在if...then语句中合并,以便默认情况下的操作只有1.不确定为什么在这种情况下这不适用于Devise

我需要做的是用户是否被确认,在他/她成功注册后立即我需要POST到另一个控制器来创建其他东西,这就是redirect_to是相同的原因。但我收到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

1 个答案:

答案 0 :(得分:0)

<div my-component binding-foo="foo"> <strong>get:</strong> {{isolatedBindingFoo}} // get it to output foo? </div> 进行渲染,然后respond_withafter_sign_up_path_for进行重定向,您同时调用after_inactive_sign_up_path_for和其中一种方法在同一行代码上。