Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.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 将recaptcha消息错误附加到rails errors.messages.values_Ruby On Rails_Ruby_Warnings - Fatal编程技术网

Ruby on rails 将recaptcha消息错误附加到rails errors.messages.values

Ruby on rails 将recaptcha消息错误附加到rails errors.messages.values,ruby-on-rails,ruby,warnings,Ruby On Rails,Ruby,Warnings,我在控制器中有这样的代码: if verify_recaptcha #verify_recaptcha(:model => @order, :message => "Oh! It's error with reCAPTCHA!") && respond_to do |format| if @order.save Cart.destroy(session[:cart_id]) session[:car

我在控制器中有这样的代码:

if verify_recaptcha #verify_recaptcha(:model => @order, :message => "Oh! It's error with reCAPTCHA!") && 
      respond_to do |format|
        if @order.save
          Cart.destroy(session[:cart_id])
          session[:cart_id] = nil
          OrderMailer.order_confirmation(@order, @user).deliver
          UserOrderMailer.user_order_mailer(@order, @user).deliver
          #OrderNotifier.received(@order).deliver
          pdf_link = generate_pdf(@order)
          link = "  <a href=\"#{pdf_link}\">#{I18n.t(:get_pdf)}</a>"   
          format.html { redirect_to root_url, :notice => (I18n.t(:successful_order_send)+link.to_s).html_safe}

        else
          format.html { render :action => "new", :notice => I18n.t(:error) }
          format.xml  { render :xml => @order.errors, :status => :unprocessable_entity }

        end
      end
    else
      flash[:warning] = I18n.t(:wrong_captcha)
      redirect_to :back 
    end  
但在布局上,我也有:

- if flash[:warning]
              .warning
                = flash[:warning]
            - if flash[:notice]
              .notice
                = flash[:notice]
我想知道,我如何将recaptcha fail error追加到errors.messages.values错误列表中,并以与模型验证消息相同的div和li显示? 我怎样才能将另一个li项目看作是TCHA消息

if verify_recaptcha
  ...
else
  @user_vehicle.errors.add(:base, I18n.t(:wrong_captcha))
end
if verify_recaptcha
  ...
else
  @user_vehicle.errors.add(:base, I18n.t(:wrong_captcha))
end