我尝试在设计上使用recaptcha。每次我将代码放入 racaptcha 并提交表单时,我都会收到“recaptcha-not-reachable”消息。几天前,recaptcha 工作正常,但现在我总是收到消息“recaptcha-not-reachable”,我真的不知道为什么。
看法
<div class="password">
<p class="forgot">Forgot your password?</p>
<hr class="style-six">
<div class="row">
<div class="email">
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => {:id => "renew", :class => "form-horizontal", :method => :post }) do |f| %>
<div class="control-group mailinput">
<%= f.email_field :email, :placeholder => "Email", :autofocus => true, :required => true %>
</div>
<%= recaptcha_tags :display => { :theme => 'white' } %>
<div class="control-group">
<%= f.button "Re-new password", :class => "btn btn-primary" %>
</div>
<% end %>
</div>
</div>
</div>
控制器
class PasswordsController < Devise::PasswordsController
layout 'xxxx_layout'
# POST /resource/password
def create
if verify_recaptcha
self.resource = resource_class.send_reset_password_instructions(resource_params)
if successfully_sent?(resource)
respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
else
flash.delete :recaptcha_error
flash.now[:error] = t("error.user.noexist")
render "passwords/new"
end
else
build_resource
clean_up_passwords(resource)
flash.now[:alert] = "There was an error with the recaptcha code below. Please re-enter the code."
#flash.delete :recaptcha_error
render "passwords/new"
end
end
end
根
get 'password/new' => 'passwords#new', :as => :new_user_password
post 'password' => 'passwords#create', :as => :user_password
get 'password/edit' => 'passwords#edit', :as => :edit_user_password
put 'password' => 'passwords#update'
/config/initializers/recaptcha.rb
Recaptcha.configure do |config|
config.public_key = 'xxxxxxx'
config.private_key = 'xxxxxxx'
config.proxy = 'http://127.0.0.1:3000'
end
配置/应用程序.rb
require "net/http"