Rails ReCaptcha:站点密钥 reCAPTCHA 无效
Rails ReCaptcha: Invalid site key reCAPTCHA
我一直收到 reCaptcha 错误
ERROR for site owner:
Invalid site key
我正在本地主机上进行测试,所以我知道这可能会导致一些问题,但我正在使用 Google 提供的密钥专门 进行测试found here.
recaptcha.rb 配置
Recaptcha.configure do |config|
config.public_key = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
config.public_key = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
end
评论控制器
def create
@review = Review.create(review_params)
@review.professor_id = @professor.id
@review.guest = :guest
respond_to do |format|
if verify_recaptcha(model: @review) && @review.save
format.html{ redirect_to @professor, notice: 'Review was successfully created.' }
format.json { render :show, status: :created, location: @review }
else
format.html { render :new, notice: 'Please fill out the captcha.'}
format.json { render json: @review.errors, status: :unprocessable_entity}
end
end
end
论坛
<%= raw recaptcha_tags %>
<div class="actions">
<%= f.submit %>
</div>
你打错了。您已经写了两次 config.public_key
。
它应该是 config.public_key
和 config.private_key
并且它的值分别是
我一直收到 reCaptcha 错误
ERROR for site owner:
Invalid site key
我正在本地主机上进行测试,所以我知道这可能会导致一些问题,但我正在使用 Google 提供的密钥专门 进行测试found here.
recaptcha.rb 配置
Recaptcha.configure do |config|
config.public_key = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
config.public_key = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
end
评论控制器
def create
@review = Review.create(review_params)
@review.professor_id = @professor.id
@review.guest = :guest
respond_to do |format|
if verify_recaptcha(model: @review) && @review.save
format.html{ redirect_to @professor, notice: 'Review was successfully created.' }
format.json { render :show, status: :created, location: @review }
else
format.html { render :new, notice: 'Please fill out the captcha.'}
format.json { render json: @review.errors, status: :unprocessable_entity}
end
end
end
论坛
<%= raw recaptcha_tags %>
<div class="actions">
<%= f.submit %>
</div>
你打错了。您已经写了两次 config.public_key
。
它应该是 config.public_key
和 config.private_key
并且它的值分别是