Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Ruby on Rails中reCaptcha的重复错误消息_Ruby On Rails_Ruby_Recaptcha - Fatal编程技术网

Ruby on rails Ruby on Rails中reCaptcha的重复错误消息

Ruby on rails Ruby on Rails中reCaptcha的重复错误消息,ruby-on-rails,ruby,recaptcha,Ruby On Rails,Ruby,Recaptcha,出于某种奇怪的原因,我的reCaptcha验证失败错误不断重复,如下所示: 这是我的控制器代码: def create #render plain: params[:student].inspect @student = Student.new(student_params) @recaptcha_succeeded = verify_recaptcha(model: @student) if verify_recaptcha(m

出于某种奇怪的原因,我的reCaptcha验证失败错误不断重复,如下所示:

这是我的控制器代码:

def create
        #render plain: params[:student].inspect
        @student = Student.new(student_params)
        @recaptcha_succeeded = verify_recaptcha(model: @student)
        if verify_recaptcha(model: @student) && @student.save
            redirect_to @student
        else
            render 'new'
        end
以下是查看html代码:

<%if @recaptcha_succeeded==false%>
                  <div class="col-md-12">
                    <h5><%=@student.errors.size%> error prohibited this student from being saved:</h5>
                    <%@student.errors.full_messages.each do |message|%>
                      <li><%=message%></li>
                    <%end%>
                  </div>
              <%end%>

错误禁止保存此学生:

  • 有什么提示吗?

    您两次调用verify\u recaptcha方法,因此出现了这两个错误。您可以使用
    @recaptcha\u successed
    变量中存储的
    verify\u recaptcha
    结果避免两次调用

    def创建
    #呈现普通:参数[:学生]。检查
    @学生=学生。新建(学生参数)
    @recaptcha_Successed=验证_recaptcha(模型:@student)
    如果@repatch_成功&&@student.save
    将_重定向到@student
    其他的
    呈现“新”
    结束
    结束
    
    能否向我们展示您的
    verify\u recaptcha
    方法?@sureshraprasanna70它使用的是来自的recaptcha gem,对于特定的verify\u recaptcha方法,它位于此处,请随意向上投票。@sureshraprasanna70“请参阅”以及链接页面和。寻求调试帮助的问题(“此代码为什么不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现所需的最短代码。请参阅:。