2

I have contact form and sendcontact action respon with js, before use reCaptcha gem, send contact is works.

  • gem 'recaptcha', :require => 'recaptcha/rails'
  • public and private key
  • recaptcha.rb
Recaptcha.configure do |config|
  config.public_key  = '6LcPi-zzzzzzzzz'
  config.private_key = '6LcPi-xxxxxxxxx'
  config.proxy = 'http://localhost:3000/'
end

Here's form and controller

  # contact form

  <%= form_for Contact.new, :url => { :action => "sendcontact" }, :remote => true  do |f| %> 
 <div class="field">
  <%= f.label :name %><br />
  <%= f.text_field :name %>
 </div>
 <div class="field">
   <%= f.label :email %><br />
   <%= f.text_field :email %>
 </div>
 <div class="field">
   <%= f.label :message %><br />
   <%= f.text_area :message, :style => 'height:200px;width:300px;resize:vertical;' %>
 </div>
 <div class="field">
    <%= recaptcha_tags %>
 </div>
 <div class="actions">
    <%= f.submit "Send", :class => 'btn btn-success btn-large' %>
 </div>
 <% end %>

 #controller

 def sendcontact
    @contact = Contact.new(params[:contact])
    if verify_recaptcha
       @contact.save!
       respond_to do |format|
         flash.now[:notice] = 'Thank you for contacting me'
         format.js
       end
    else
       respond_to do |format|
         format.js
       end
    end
  end

when submit form, always display notice Recaptcha unreachable

4

1 回答 1

3

解决了

只需删除config.proxy = 'http://localhost:3000/'

因为我没有使用代理并且http://localhost:3000/不是代理所以验证验证码不发送到服务器谷歌并显示警报“recaptcha unreachable”

超时结束时显示“Recaptcha Unreachable”。

这是救援超时::错误https://github.com/ambethia/recaptcha/blob/master/lib/recaptcha/verify.rb#L53

于 2013-06-30T13:16:06.587 回答