我经常同时使用render
和redirect_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
答案 0 :(得分:0)
<div my-component binding-foo="foo">
<strong>get:</strong> {{isolatedBindingFoo}} // get it to output foo?
</div>
进行渲染,然后respond_with
和after_sign_up_path_for
进行重定向,您同时调用after_inactive_sign_up_path_for
和其中一种方法在同一行代码上。