导轨 - 更新电子邮件,制定用户

问题描述:

我有以下profile_controller的行动:导轨 - 更新电子邮件,制定用户

def update 
    updated = if _profile_params[:password].present? 
    current_user.skip_confirmation! 
    current_user.update_with_password(_profile_params) 
    else 
    current_user.skip_confirmation! 
    current_user.update(_profile_params) 
    end 

    if updated 
    render json: ProfilePresenter::Public.new(current_user) 
    else 
    render status: :unprocessable_entity, 
     json: Oj.dump({ errors: current_user.errors.messages }) 
    end 
end 

如果我把控制器以下有效载荷:

{"first_name":"Aieie", "phone": "+393345678909", "email": "[email protected]"} 

系统生成的确认邮件,即使我用skip_confirmation!来跳过它。

如何避免系统发送确认电子邮件?

当你调用它,而更新和保存之前,你需要做的:

current_user.skip_reconfirmation! 

记得skip_reconfirmation!

好的,这是一个容易的。只要使用.skip_reconfirmation!doc